Class DIYSheet
- java.lang.Object
-
- ca.cgjennings.apps.arkham.sheet.Sheet<DIY>
-
- ca.cgjennings.apps.arkham.diy.DIYSheet
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ca.cgjennings.apps.arkham.sheet.Sheet
Sheet.DeckSnappingHint
-
-
Field Summary
-
Fields inherited from class ca.cgjennings.apps.arkham.sheet.Sheet
ALIGN_CENTER, ALIGN_LEADING, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_TRAILING, DEBUG_BLEED_MARGIN, DEBUG_PORTRAIT_REGION, DEBUG_UNSAFE_AREA, ON_PAINT_EVENT_METHOD, ROTATE_LEFT, ROTATE_NONE, ROTATE_RIGHT, ROTATE_UPSIDE_DOWN
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
applyContextHints(java.awt.Graphics2D g)
This method can be called from a painting function to set rendering hints on a graphics context.double
getBleedMargin()
Returns the size of the bleed margin around the component edge that should be cropped off, measured in points.Sheet.DeckSnappingHint
getDeckSnappingHint()
Returns a hint describing how this sheet should behave when snapped in a deck.double[]
getFoldMarks()
Returns an array that describes the extra fold marks that should appear on this face when it is placed in a deck.MarkerStyle
getMarkerStyle()
If this sheet represents an embedded marker, returns the layout style of the marker.PrintDimensions
getPrintDimensions()
Return the printed size of the sheet, measured in points.RenderTarget
getRenderTarget()
Returns the currently requested target when called while the sheet is being drawn.int
getSheetIndex()
Returns the index of this sheet.boolean
hasFoldMarks()
Returnstrue
if this sheet should have special fold marks added when printed.When this returnstrue
one or more fold marks will be shown at locations determined bySheet.getFoldMarks()
.boolean
isHighResolutionRendering()
Returnstrue
if the current or most recent rendering was being done in high resolution mode.boolean
isTransparent()
Returnstrue
if the sheets for this card are transparent.boolean
isVariableSize()
Returnstrue
if the sheets created by this card can vary in size.void
paintImage(java.awt.Graphics2D g, java.awt.image.BufferedImage image, java.awt.Rectangle region)
Paints an image at the specified location and size.void
paintImage(java.awt.Graphics2D g, java.awt.image.BufferedImage image, java.lang.String regionKey)
Paints an image at the specified location and size.void
paintImage(java.awt.Graphics2D g, java.lang.String sharedKey)
Paints an image at a location and size that are taken from a region setting.void
paintImage(java.awt.Graphics2D g, java.lang.String imageKey, int x, int y)
Paints an image at its normal size at the specified location.void
paintImage(java.awt.Graphics2D g, java.lang.String imageKey, int x, int y, int width, int height)
Paints an image at the specified location and size.void
paintImage(java.awt.Graphics2D g, java.lang.String imageKey, java.lang.String regionKey)
Paints an image at a location and size that are taken from a region setting.void
paintMarkerPortrait(java.awt.Graphics2D g)
Paints the portrait within the marker clip region for components with theDIY.FaceStyle.CARD_AND_MARKER
face style.void
paintNumberedImage(java.awt.Graphics2D g, java.lang.String sharedKey, int number)
Paints a numbered image at a location and size that are taken from a region setting.void
paintPortrait(java.awt.Graphics2D g)
protected void
paintSheet(RenderTarget target)
Paints the content of this sheet.void
paintTemplateImage(java.awt.Graphics2D g)
Paints the card template image that was set when the card was created.java.lang.String
toString()
-
Methods inherited from class ca.cgjennings.apps.arkham.sheet.Sheet
allowTemplateUseInBleedSynthesis, applyContextScale, applyFinishingOptions, centerTitle, createGraphics, createGraphics, createTemporaryImage, doStandardRendererInitialization, drawOutlinedTitle, drawPortraitBox, drawPortraitBox, drawRegionBox, drawRotatedTitle, drawTitle, fitTitle, freeCachedResources, getCornerRadius, getDestinationBuffer, getExpansionSymbol, getExpansionSymbolKey, getGameComponent, getPaintingResolution, getRenderedBleedMargin, getScalingFactor, getSuggestedUpsampleFactor, getTemplateHeight, getTemplateImage, getTemplateKey, getTemplateResolution, getTemplateWidth, getUserBleedMargin, hasChanged, hasCropMarks, initializeTemplate, initializeTemplate, isCachedTemporaryImageInvalid, isMarginSynthesisAllowed, isPrototypeRenderingModeEnabled, markChanged, paint, paint, parseExpansionList, replaceTemplateImage, setCornerRadius, setExpansionSymbolKey, setNamesForRenderer, setPrototypeRenderingModeEnabled, setUserBleedMargin, synthesizeBleedMargin
-
-
-
-
Constructor Detail
-
DIYSheet
public DIYSheet(DIY diy, java.lang.String templateKey, int index)
Creates a new sheet for a DIY component. A sheet is not normally created directly, but is instead created by callingDIY.createDefaultSheets()
. Unlike most sheets, aDIYSheet
does not contain the sheet painting code itself, but instead defers painting to the component it was created for.- Parameters:
diy
- the component for which this sheet is being createdtemplateKey
- a template key name used to determine the basic properties of the sheetindex
- the index of the sheet (0 for front, 1 for back, and so on)- See Also:
DIY.paintFront(java.awt.Graphics2D, ca.cgjennings.apps.arkham.diy.DIY, ca.cgjennings.apps.arkham.diy.DIYSheet)
,DIY.paintBack(java.awt.Graphics2D, ca.cgjennings.apps.arkham.diy.DIY, ca.cgjennings.apps.arkham.diy.DIYSheet)
-
-
Method Detail
-
getSheetIndex
public int getSheetIndex()
Returns the index of this sheet. This can be used to differentiate which face to drawn when the component has more than two faces. Even-numbered sheets are drawn by callingDIY.paintFront(java.awt.Graphics2D, ca.cgjennings.apps.arkham.diy.DIY, ca.cgjennings.apps.arkham.diy.DIYSheet)
, while odd-numbered sheets are drawn by callingDIY.paintBack(java.awt.Graphics2D, ca.cgjennings.apps.arkham.diy.DIY, ca.cgjennings.apps.arkham.diy.DIYSheet)
.- Returns:
- the index of the face, counting from 0
-
paintSheet
protected void paintSheet(RenderTarget target)
Description copied from class:Sheet
Paints the content of this sheet. This method will be called by the framework whenever the sheet needs to be redrawn.A typical procedure to set up for painting is to call
Sheet.createGraphics()
to get a graphics context for the sheet's internal image buffer. The returned context will be scaled so that 1 unit in the graphics context is equal to 1 pixel in the template image, and the context will be configured appropriately for the current rendering target. In some cases you may wish to perform these steps in stages, in which case you can useSheet.createGraphics(java.awt.image.BufferedImage, boolean, boolean)
,Sheet.applyContextHints(java.awt.Graphics2D)
andSheet.applyContextScale(java.awt.Graphics2D)
.- Specified by:
paintSheet
in classSheet<DIY>
- Parameters:
target
- the rendering target
-
getRenderTarget
public RenderTarget getRenderTarget()
Returns the currently requested target when called while the sheet is being drawn. When called at any other time, returns the target of the most recent render request.- Returns:
- the current render target
-
applyContextHints
public void applyContextHints(java.awt.Graphics2D g)
This method can be called from a painting function to set rendering hints on a graphics context. (These are normally set automatically on the graphics context passed to the painter.)- Overrides:
applyContextHints
in classSheet<DIY>
- Parameters:
g
- the graphics context to modify- See Also:
Sheet.createGraphics(java.awt.image.BufferedImage, boolean, boolean)
,Sheet.createTemporaryImage(int, int, boolean)
-
isHighResolutionRendering
public boolean isHighResolutionRendering()
Returnstrue
if the current or most recent rendering was being done in high resolution mode. To returntrue
, one of the following statements must hold:- the high resolution substitution mode is set to
FORCE
, or - the high resolution substitution mode is set to
ENABLE
, the render target is eitherPRINT
orEXPORT
, and the requested resolution is greater than the resolution of the template image.
When this method returns
true
, painting methods should use the highest resolution source images available.- Returns:
true
if in "high resolution" mode- Since:
- 2.1a11
- the high resolution substitution mode is set to
-
paintImage
public void paintImage(java.awt.Graphics2D g, java.lang.String imageKey, int x, int y)
Paints an image at its normal size at the specified location. This method will perform automatic high resolution image substitution if there is a key with same name asimageKey
but with"-hires"
appended.- Parameters:
g
- the graphics context to use for paintingimageKey
- the settings key of the imagex
- the horizontal offset from the left side of the template imagey
- the vertical offset from the top edge of the template image
-
paintImage
public void paintImage(java.awt.Graphics2D g, java.lang.String imageKey, java.lang.String regionKey)
Paints an image at a location and size that are taken from a region setting. This method will perform automatic high resolution image substitution if there is a key with same name asimageKey
but with"-hires"
appended.- Parameters:
g
- the graphics context to use for paintingimageKey
- the settings key of the imageregionKey
- the settings key of the region where the image should be drawn, without the "-region" suffix
-
paintImage
public void paintImage(java.awt.Graphics2D g, java.lang.String sharedKey)
Paints an image at a location and size that are taken from a region setting. The image resource is determined from the value of sharedKey, while the region is obtained by concatenating "-region" to the shared key name. This method will perform automatic high resolution image substitution if there is a key with same name assharedKey
but with"-hires"
appended.- Parameters:
g
- the graphics context to use for paintingsharedKey
- the settings key of the image, and base name of the region key
-
paintImage
public void paintImage(java.awt.Graphics2D g, java.lang.String imageKey, int x, int y, int width, int height)
Paints an image at the specified location and size. This method will perform automatic high resolution image substitution if there is a key with same name asimageKey
but with"-hires"
appended.- Parameters:
g
- the graphics context to use for paintingimageKey
- the settings key of the imagex
- the horizontal offset from the left side of the template imagey
- the vertical offset from the top edge of the template imagewidth
- the width of the imageheight
- the height of the image
-
paintNumberedImage
public void paintNumberedImage(java.awt.Graphics2D g, java.lang.String sharedKey, int number)
Paints a numbered image at a location and size that are taken from a region setting. This is similar to painting an image with a shared key, but the image to paint is determined usingSettings.getNumberedImageResource(java.lang.String, int)
. The image resource is determined from the value of sharedKey and number, while the region is obtained by concatenating "-region" to the shared key name. This method will perform automatic high resolution image substitution if there is a key with same name assharedKey
but with"-hires"
appended.- Parameters:
g
- the graphics context to use for paintingsharedKey
- the settings key of the image, and base name of the region keynumber
- the number of the image to load
-
paintImage
public void paintImage(java.awt.Graphics2D g, java.awt.image.BufferedImage image, java.lang.String regionKey)
Paints an image at the specified location and size.- Parameters:
g
- the graphics context to use for paintingimage
- the image to drawregionKey
- the settings key of the region where the image should be drawn, without the "-region" suffix
-
paintImage
public void paintImage(java.awt.Graphics2D g, java.awt.image.BufferedImage image, java.awt.Rectangle region)
Paints an image at the specified location and size.- Parameters:
g
- the graphics context to use for paintingimage
- the image to drawregion
- the region in which to draw the image
-
paintTemplateImage
public void paintTemplateImage(java.awt.Graphics2D g)
Paints the card template image that was set when the card was created. This method can perform automatic high resolution image substitution if there is a key with same name as the template key but with"-hires"
appended.- Parameters:
g
- the graphics context to use for painting
-
paintPortrait
public void paintPortrait(java.awt.Graphics2D g)
-
paintMarkerPortrait
public void paintMarkerPortrait(java.awt.Graphics2D g)
Paints the portrait within the marker clip region for components with theDIY.FaceStyle.CARD_AND_MARKER
face style.- Parameters:
g
- the graphics context to paint the marker portrait into- Throws:
java.lang.IllegalStateException
- if the component is not aCARD_AND_MARKER
type
-
isTransparent
public boolean isTransparent()
Description copied from class:Sheet
Returnstrue
if the sheets for this card are transparent. The base class returnsfalse
; subclasses that want to create non-rectangular card faces must override this method. When this method returnstrue
, the framework guarantees the following:- the image buffer used for drawing will have an alpha channel (that is, it will keep track of how opaque each pixel is)
- the image buffer used for drawing will be completely transparent
(alpha = 0) at the start of each call to
Sheet.paint(ca.cgjennings.apps.arkham.sheet.RenderTarget, double)
- Overrides:
isTransparent
in classSheet<DIY>
- Returns:
true
if the card face may contain transparent or translucent areas
-
isVariableSize
public boolean isVariableSize()
Description copied from class:Sheet
Returnstrue
if the sheets created by this card can vary in size. Subclasses that wish to create variably-sized sheets must override this method to returntrue
.Typically a variably-sized sheet is also transparent. When this is the case, and the sheet image has one or more edges that are completely transparent after
Sheet.paint(ca.cgjennings.apps.arkham.sheet.RenderTarget, double)
returns, then the transparent edges will be trimmed from the outside of the sheet and the size adjusted accordingly. Alternatively (or additionally), the size can be altered by replacing the template image at the start of painting.- Overrides:
isVariableSize
in classSheet<DIY>
- Returns:
- true if this card can have different sizes
- See Also:
Sheet.isTransparent()
,Sheet.replaceTemplateImage(java.awt.image.BufferedImage)
-
getDeckSnappingHint
public Sheet.DeckSnappingHint getDeckSnappingHint()
Description copied from class:Sheet
Returns a hint describing how this sheet should behave when snapped in a deck. The default isCARD
, meaning that the sheet behaves like one face of a playing card.- Overrides:
getDeckSnappingHint
in classSheet<DIY>
- Returns:
- a hint describing the default behaviour of this face when it is snapped against other objects in a deck
-
getBleedMargin
public double getBleedMargin()
Description copied from class:Sheet
Returns the size of the bleed margin around the component edge that should be cropped off, measured in points. This bleed margin allows for slight misalignment when cutting the component from a larger sheet of paper. The bleed margin will be the same on all sides. The height and width of the component after cutting will be less than the original by twice this margin. IfSheet.hasCropMarks()
returnstrue
, then the automatic crop marks will be moved toward the inside of this component by an amount equal to the bleed margin.The base class looks up the setting templateKey
-bleed-margin
to determine the bleed margin, defaulting to 0 if none is defined.In the example below, the actual component to be cut and kept is indicated by the blank area, while the X'd area indicates the bleed margin. Component content covers the entire area, including the bleed margin, but nothing important should appear in the bleed margin or within a distance about the same size as the bleed margin on the component interior.
XXXXXXXXXXXXXXXXXX XX XX X X X X X Actual X X Component X X Content X X (tm) X X X X X X X XX XX XXXXXXXXXXXXXXXXXX
By default, this method returns 0, meaning that the design includes no bleed margin. If the bleed margin is 0, Strange Eons will attempt to synthesize bleed margin graphics, with varying results. Note that Strange Eons will not synthesize a bleed margin for transparent sheet images (i.e., if
Sheet.isTransparent()
is true).- Overrides:
getBleedMargin
in classSheet<DIY>
- Returns:
- the size of the bleed margin, in points (1 point = 1/72 inch)
- See Also:
Sheet.hasCropMarks()
-
getFoldMarks
public double[] getFoldMarks()
Description copied from class:Sheet
Returns an array that describes the extra fold marks that should appear on this face when it is placed in a deck. This method is only called ifSheet.hasFoldMarks()
returnstrue
. It should return an array of double values. Each fold mark to be added by the deck is described by a sequence of four doubles in the array. The first pair is the location of a start point for the fold mark (in x, y order). The location is relative to the width and height of the face, so for example the pair (0.5, 0) would start a fold mark in the center of the top edge. The second pair is a unit vector that describes the direction that the fold mark should extend from the start point. (Recall that a unit vector is a vector of length one, that is, sqrt(x2+y2) == 1.)Fold marks typically come in pairs, one on each side of the face. For example, the following fold mark array would indicate the face should be folded in half along the vertical axis by placing fold marks at the centers of the top and bottom edges:
[0.5, 0, 0, -1, 0.5, 1, 0, 1]
The base class returns
null
.- Overrides:
getFoldMarks
in classSheet<DIY>
- Returns:
- an array of quadruples that describe the location and angle of additional fold marks to be drawn around the component
-
hasFoldMarks
public boolean hasFoldMarks()
Description copied from class:Sheet
Returnstrue
if this sheet should have special fold marks added when printed.When this returnstrue
one or more fold marks will be shown at locations determined bySheet.getFoldMarks()
. This can be used to produce complex 3D components that require assembly before use.Note that the fold marks produced by this method are completely independent of the marks that are sometimes generated automatically from crop marks (see
Sheet.hasCropMarks()
).The base class returns
false
.- Overrides:
hasFoldMarks
in classSheet<DIY>
- Returns:
- true if
Sheet.getFoldMarks()
should be consulted for the location of special fold marks
-
getPrintDimensions
public PrintDimensions getPrintDimensions()
Description copied from class:Sheet
Return the printed size of the sheet, measured in points. The returned size will account for the current bleed margin settings.The base class implementation is only valid for fixed-size sheets. Variable-sized sheets must override this method to return the correct size.
- Overrides:
getPrintDimensions
in classSheet<DIY>
- Returns:
- the dimensions of the bounding rectangle of this sheet when printed
-
getMarkerStyle
public MarkerStyle getMarkerStyle()
Description copied from class:Sheet
If this sheet represents an embedded marker, returns the layout style of the marker. For regular sheets, this method returnsnull
. (The base class returnsnull
.)- Overrides:
getMarkerStyle
in classSheet<DIY>
- Returns:
- the token style of the embedded token, or
null
for standard sheets
-
-