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 voidapplyContextHints(java.awt.Graphics2D g)This method can be called from a painting function to set rendering hints on a graphics context.doublegetBleedMargin()Returns the size of the bleed margin around the component edge that should be cropped off, measured in points.Sheet.DeckSnappingHintgetDeckSnappingHint()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.MarkerStylegetMarkerStyle()If this sheet represents an embedded marker, returns the layout style of the marker.PrintDimensionsgetPrintDimensions()Return the printed size of the sheet, measured in points.RenderTargetgetRenderTarget()Returns the currently requested target when called while the sheet is being drawn.intgetSheetIndex()Returns the index of this sheet.booleanhasFoldMarks()Returnstrueif this sheet should have special fold marks added when printed.When this returnstrueone or more fold marks will be shown at locations determined bySheet.getFoldMarks().booleanisHighResolutionRendering()Returnstrueif the current or most recent rendering was being done in high resolution mode.booleanisTransparent()Returnstrueif the sheets for this card are transparent.booleanisVariableSize()Returnstrueif the sheets created by this card can vary in size.voidpaintImage(java.awt.Graphics2D g, java.awt.image.BufferedImage image, java.awt.Rectangle region)Paints an image at the specified location and size.voidpaintImage(java.awt.Graphics2D g, java.awt.image.BufferedImage image, java.lang.String regionKey)Paints an image at the specified location and size.voidpaintImage(java.awt.Graphics2D g, java.lang.String sharedKey)Paints an image at a location and size that are taken from a region setting.voidpaintImage(java.awt.Graphics2D g, java.lang.String imageKey, int x, int y)Paints an image at its normal size at the specified location.voidpaintImage(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.voidpaintImage(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.voidpaintMarkerPortrait(java.awt.Graphics2D g)Paints the portrait within the marker clip region for components with theDIY.FaceStyle.CARD_AND_MARKERface style.voidpaintNumberedImage(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.voidpaintPortrait(java.awt.Graphics2D g)protected voidpaintSheet(RenderTarget target)Paints the content of this sheet.voidpaintTemplateImage(java.awt.Graphics2D g)Paints the card template image that was set when the card was created.java.lang.StringtoString()-
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, aDIYSheetdoes 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:SheetPaints 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:
paintSheetin 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:
applyContextHintsin 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()
Returnstrueif 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 eitherPRINTorEXPORT, 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:
trueif 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 asimageKeybut 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 asimageKeybut 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 assharedKeybut 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 asimageKeybut 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 assharedKeybut 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_MARKERface style.- Parameters:
g- the graphics context to paint the marker portrait into- Throws:
java.lang.IllegalStateException- if the component is not aCARD_AND_MARKERtype
-
isTransparent
public boolean isTransparent()
Description copied from class:SheetReturnstrueif 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:
isTransparentin classSheet<DIY>- Returns:
trueif the card face may contain transparent or translucent areas
-
isVariableSize
public boolean isVariableSize()
Description copied from class:SheetReturnstrueif 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:
isVariableSizein 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:SheetReturns 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:
getDeckSnappingHintin 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:SheetReturns 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-marginto 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:
getBleedMarginin 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:SheetReturns 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:
getFoldMarksin 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:SheetReturnstrueif this sheet should have special fold marks added when printed.When this returnstrueone 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:
hasFoldMarksin 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:SheetReturn 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:
getPrintDimensionsin classSheet<DIY>- Returns:
- the dimensions of the bounding rectangle of this sheet when printed
-
getMarkerStyle
public MarkerStyle getMarkerStyle()
Description copied from class:SheetIf this sheet represents an embedded marker, returns the layout style of the marker. For regular sheets, this method returnsnull. (The base class returnsnull.)- Overrides:
getMarkerStylein classSheet<DIY>- Returns:
- the token style of the embedded token, or
nullfor standard sheets
-
-