ca.cgjennings.apps.arkham.diy
Class DIY

java.lang.Object
  extended by AbstractPortraitComponent
      extended by ca.cgjennings.apps.arkham.diy.DIY
All Implemented Interfaces:
Handler

public class DIY
extends AbstractPortraitComponent
implements Handler

A scriptable game component type.


Nested Class Summary
static class DIY.FaceStyle
          The type of card faces created by a DIY component.
static class DIY.HighResolutionMode
          The valid modes for high resolution image substitution.
 
Field Summary
static int OPT_MIN_PORTRAIT_SCALE
           
static int OPT_NO_PORTRAIT_CLIP
           
static int OPT_NO_PORTRAIT_FILL
           
static int OPT_NO_QUALITY_INIT
           
static int OPT_TRANSPARENT
           
static int OPT_VARIABLE_SIZE
           
 
Constructor Summary
protected DIY(Handler handler)
           
  DIY(java.lang.String handlerScript)
           
  DIY(java.lang.String handlerScript, boolean debug)
           
 
Method Summary
 void clearAll()
           
 double computeIdealScaleForImage(java.awt.image.BufferedImage image, java.lang.String imageKey)
          This is overridden to use the portrait clipping region instead of separate portrait width and height keys.
 double computeMinimumScaleForImage(java.awt.image.BufferedImage image, java.lang.String imageKey)
          This is overridden to use the portrait clipping region instead of separate portrait width and height keys.
 void create(DIY diy)
           
 void createBackPainter(DIY diy, DIYSheet sheet)
           
 AbstractEditor createDefaultEditor()
           
 CharacterSheet[] createDefaultSheets()
           
 void createFrontPainter(DIY diy, DIYSheet sheet)
           
 void createInterface(DIY diy, DIYEditor editor)
           
static DIY createTestInstance(Handler h)
           
 void dispose()
           
 int getAdvancedFlags()
          Deprecated.  
 java.lang.String getBackTemplateKey()
           
 double getBleedMargin()
           
 int getCardVersion()
           
 double[] getCustomFoldMarks(int faceIndex)
           
 DeckSnappingHint getDeckSnappingHint()
           
 java.lang.String getExtensionName()
           
 DIY.FaceStyle getFaceStyle()
           
 java.lang.String getFrontTemplateKey()
           
 java.lang.String getHandlerScript()
           
 DIY.HighResolutionMode getHighResolutionSubstitutionMode()
           
 javax.swing.text.JTextComponent getNameField()
           
 boolean getPortraitClipping()
           
 java.lang.String getPortraitKey()
           
 boolean getPortraitScaleUsesMinimum()
           
 boolean getTransparentFaces()
           
 boolean getVariableSizedFaces()
           
 void init()
           
protected  void installDefaultPortrait()
           
 boolean isAdvancedFlagAvailable(int advancedFlags)
          Returns true if all of the specified flags are available in this version of the DIY system.
 boolean isPortraitBackgroundFilled()
          Returns true if portrait areas will be filled with solid white before painting the portrait.
 void onClear(DIY diy)
           
 void onRead(DIY diy, java.io.ObjectInputStream objectInputStream)
           
 void onWrite(DIY diy, java.io.ObjectOutputStream objectOutputStream)
           
 void paintBack(java.awt.Graphics2D g, DIY diy, DIYSheet sheet)
           
 void paintFront(java.awt.Graphics2D g, DIY diy, DIYSheet sheet)
           
 void setAdvancedFlags(int advancedFlags)
          Deprecated.  
 void setBackTemplateKey(java.lang.String backTemplateKey)
           
 void setBleedMargin(double marginInPoints)
           
 void setCardVersion(int cardVersion)
           
 void setCustomFoldMarks(int faceIndex, double[] foldMarkVectors)
           
 void setDeckSnappingHint(DeckSnappingHint deckSnappingHint)
           
 void setExtensionName(java.lang.String extensionName)
           
 void setFaceStyle(DIY.FaceStyle faceStyle)
           
 void setFrontTemplateKey(java.lang.String frontTemplateKey)
           
 void setHighResolutionSubstitutionMode(DIY.HighResolutionMode mode)
           
 void setName(java.lang.String name)
           
 void setNameField(javax.swing.text.JTextComponent nameField)
           
 void setPortrait(java.lang.String portraitImage)
           
 void setPortraitBackgroundFilled(boolean fill)
          If set, the portrait clip region will not be filled in with solid white before painting the portrait.
 void setPortraitClipping(boolean variable)
           
 void setPortraitKey(java.lang.String portraitKey)
           
 void setPortraitScaleUsesMinimum(boolean variable)
           
 void setTransparentFaces(boolean transparent)
          This flag must be set if the card faces require support for translucent pixels; for example, if the faces have shaped edges.
 void setVariableSizedFaces(boolean variable)
           
 java.lang.String toString()
           
 void upgradeOldPropertyNames()
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OPT_NO_PORTRAIT_FILL

public static final int OPT_NO_PORTRAIT_FILL
See Also:
Constant Field Values

OPT_NO_QUALITY_INIT

public static final int OPT_NO_QUALITY_INIT
See Also:
Constant Field Values

OPT_TRANSPARENT

public static final int OPT_TRANSPARENT
See Also:
Constant Field Values

OPT_VARIABLE_SIZE

public static final int OPT_VARIABLE_SIZE
See Also:
Constant Field Values

OPT_MIN_PORTRAIT_SCALE

public static final int OPT_MIN_PORTRAIT_SCALE
See Also:
Constant Field Values

OPT_NO_PORTRAIT_CLIP

public static final int OPT_NO_PORTRAIT_CLIP
See Also:
Constant Field Values
Constructor Detail

DIY

protected DIY(Handler handler)

DIY

public DIY(java.lang.String handlerScript)
    throws java.io.IOException
Throws:
java.io.IOException

DIY

public DIY(java.lang.String handlerScript,
           boolean debug)
    throws java.io.IOException
Throws:
java.io.IOException
Method Detail

createTestInstance

public static DIY createTestInstance(Handler h)

init

public void init()
          throws java.io.IOException
Throws:
java.io.IOException

getHandlerScript

public java.lang.String getHandlerScript()

getExtensionName

public java.lang.String getExtensionName()

setExtensionName

public void setExtensionName(java.lang.String extensionName)

getCardVersion

public int getCardVersion()

setCardVersion

public void setCardVersion(int cardVersion)

getFaceStyle

public DIY.FaceStyle getFaceStyle()

setFaceStyle

public void setFaceStyle(DIY.FaceStyle faceStyle)

getFrontTemplateKey

public java.lang.String getFrontTemplateKey()

setFrontTemplateKey

public void setFrontTemplateKey(java.lang.String frontTemplateKey)

getBackTemplateKey

public java.lang.String getBackTemplateKey()

setBackTemplateKey

public void setBackTemplateKey(java.lang.String backTemplateKey)

getPortraitKey

public java.lang.String getPortraitKey()

setPortraitKey

public void setPortraitKey(java.lang.String portraitKey)

setBleedMargin

public void setBleedMargin(double marginInPoints)

getBleedMargin

public double getBleedMargin()

setHighResolutionSubstitutionMode

public void setHighResolutionSubstitutionMode(DIY.HighResolutionMode mode)

getHighResolutionSubstitutionMode

public DIY.HighResolutionMode getHighResolutionSubstitutionMode()

setCustomFoldMarks

public final void setCustomFoldMarks(int faceIndex,
                                     double[] foldMarkVectors)

getCustomFoldMarks

public final double[] getCustomFoldMarks(int faceIndex)

getAdvancedFlags

@Deprecated
public final int getAdvancedFlags()
Deprecated. 

Returns a bitmask of the currently set advanced flags. Advanced flags should only be used to provide backwards compatibility. See the documentation of setAdvancedFlags(int) for more information.

Returns:
the current advanced flag set

setAdvancedFlags

@Deprecated
public final void setAdvancedFlags(int advancedFlags)
Deprecated. 

Sets advanced flags for this DIY component. Advanced flags are boolean properties that affect how the component is drawn and how it behaves in a deck but which are not critical to its operation. Most of these options can also be set with appropriate getter/setter methods that can be called during the DIY's create() function. are normally set using getter/setter methods just like any other property, but they can also be set using a bitmask and this method. This allows you to produce a DIY component that uses a feature if it is available in a given version of SE, but which will still run in an older version if the feature is not available (without using the reflection API). Furthermore, features set as advanced flags in an older version of SE will retain the feature state in newer versions, so when the user upgrades to a new version of SE that supports the feature it will work as intended. For any case other than the one just described, it is strongly advised that you use the standard setter method to enable a desired feature. The method has been marked as deprecated for this reason.

Parameters:
advancedFlags - a bitmask specifying the combination of advanced options to use

isAdvancedFlagAvailable

public final boolean isAdvancedFlagAvailable(int advancedFlags)
Returns true if all of the specified flags are available in this version of the DIY system. See setAdvancedFlags(int) for information on advanced flags.

Parameters:
advancedFlags - the flags to test
Returns:
true if all of the features specified by the flags are available
Since:
2.00.8

setPortraitBackgroundFilled

public final void setPortraitBackgroundFilled(boolean fill)
If set, the portrait clip region will not be filled in with solid white before painting the portrait. This is usually turned off when the user is expected to use portraits that have transparency because the portrait is painted over a background illustration.

Parameters:
fill -

isPortraitBackgroundFilled

public final boolean isPortraitBackgroundFilled()
Returns true if portrait areas will be filled with solid white before painting the portrait.

Returns:

setTransparentFaces

public final void setTransparentFaces(boolean transparent)
This flag must be set if the card faces require support for translucent pixels; for example, if the faces have shaped edges.

Parameters:
transparent -

getTransparentFaces

public final boolean getTransparentFaces()

setVariableSizedFaces

public final void setVariableSizedFaces(boolean variable)

getVariableSizedFaces

public final boolean getVariableSizedFaces()

setPortraitScaleUsesMinimum

public final void setPortraitScaleUsesMinimum(boolean variable)

getPortraitScaleUsesMinimum

public final boolean getPortraitScaleUsesMinimum()

setPortraitClipping

public final void setPortraitClipping(boolean variable)

getPortraitClipping

public final boolean getPortraitClipping()

getDeckSnappingHint

public DeckSnappingHint getDeckSnappingHint()

setDeckSnappingHint

public void setDeckSnappingHint(DeckSnappingHint deckSnappingHint)

setPortrait

public void setPortrait(java.lang.String portraitImage)
                 throws java.io.IOException
Throws:
java.io.IOException

clearAll

public void clearAll()

onClear

public void onClear(DIY diy)
Specified by:
onClear in interface Handler

installDefaultPortrait

protected void installDefaultPortrait()

createDefaultSheets

public CharacterSheet[] createDefaultSheets()

createDefaultEditor

public AbstractEditor createDefaultEditor()

computeIdealScaleForImage

public double computeIdealScaleForImage(java.awt.image.BufferedImage image,
                                        java.lang.String imageKey)
This is overridden to use the portrait clipping region instead of separate portrait width and height keys.

Parameters:
image - the image to compute the ideal scale for
imageKey - this argument is ignored
Returns:
the ideal scale for the image based on the portrait clip region

computeMinimumScaleForImage

public double computeMinimumScaleForImage(java.awt.image.BufferedImage image,
                                          java.lang.String imageKey)
This is overridden to use the portrait clipping region instead of separate portrait width and height keys.

Parameters:
image - the image to compute the minimum scale for
imageKey - this argument is ignored
Returns:
the minimum scale for the image based on the portrait clip region

create

public void create(DIY diy)
Specified by:
create in interface Handler

createInterface

public void createInterface(DIY diy,
                            DIYEditor editor)
Specified by:
createInterface in interface Handler

getNameField

public javax.swing.text.JTextComponent getNameField()
Returns:
the nameField

setNameField

public void setNameField(javax.swing.text.JTextComponent nameField)
Parameters:
nameField - the nameField to set

setName

public void setName(java.lang.String name)

createFrontPainter

public void createFrontPainter(DIY diy,
                               DIYSheet sheet)
Specified by:
createFrontPainter in interface Handler

createBackPainter

public void createBackPainter(DIY diy,
                              DIYSheet sheet)
Specified by:
createBackPainter in interface Handler

paintFront

public void paintFront(java.awt.Graphics2D g,
                       DIY diy,
                       DIYSheet sheet)
Specified by:
paintFront in interface Handler

paintBack

public void paintBack(java.awt.Graphics2D g,
                      DIY diy,
                      DIYSheet sheet)
Specified by:
paintBack in interface Handler

onRead

public void onRead(DIY diy,
                   java.io.ObjectInputStream objectInputStream)
Specified by:
onRead in interface Handler

onWrite

public void onWrite(DIY diy,
                    java.io.ObjectOutputStream objectOutputStream)
Specified by:
onWrite in interface Handler

dispose

public void dispose()

toString

public java.lang.String toString()

upgradeOldPropertyNames

@Deprecated
public final void upgradeOldPropertyNames()
Deprecated. 

This method is called by DIY components that were designed before the introduction of $-notation. See the release notes for details.