Inheritance diagram for Region:
Public Member Functions | |
Region (String name, double xInches, double yInches, double wInches, double hInches) | |
For our American friends. | |
Region (String theName, Shape s, Units u) | |
Region (String name, Units x, Units y, Units w, Units h) | |
We will convert all the units to x's type. | |
void | addEventHandler (EventHandler handler) |
Keeps track of this event handler. | |
List< EventHandler > | getEventHandlers () |
Color | getFillColor () |
Units | getHeight () |
String | getIsActiveString () |
String | getName () |
double | getOpacity () |
Units | getOriginX () |
Units | getOriginY () |
Sheet | getParentSheet () |
RegionRenderer | getRenderer () |
Subclasses should override this, to customize rendering. | |
double | getScaleX () |
double | getScaleY () |
Shape | getShape () |
Subclasses can modify the internal shape object. | |
Color | getStrokeColor () |
Units | getUnits () |
TODO: We should make sure that Units objects immutable if possible. | |
Rectangle2D | getUnscaledBounds2D () |
Units | getUnscaledBoundsHeight () |
Units | getUnscaledBoundsWidth () |
Shape | getUnscaledShapeCopy () |
Units | getWidth () |
boolean | isActive () |
boolean | isVisible () |
void | resetScale () |
Resets to the default scaling factors. | |
void | scaleRegion (double sX, double sY) |
Scales the points in the current region by a horizontal and vertical multiplier. | |
void | scaleRegionUniformly (double scale) |
Resizes the region uniformly in x and y. | |
void | setActive (boolean isRegionActive) |
void | setFillColor (Color theFillColor) |
void | setName (String theName) |
void | setOpacity (double theOpacityFrom0To1) |
void | setParentSheet (Sheet sheet) |
For traversing up the UI hierarchy, in Event Visualizations. | |
void | setScale (double newScaleX, double newScaleY) |
Replaces the scaling factors. | |
void | setStrokeColor (Color strokeCol) |
void | setVisible (boolean v) |
String | toString () |
Please override for more interesting output. | |
Protected Member Functions | |
Region (String theName, Units u) | |
A protected constructor so subclasses can assign the shape whichever way they please. | |
void | setShape (Shape s) |
Subclasses can use this method to set the shape after constructing the object. | |
Protected Attributes | |
Units | referenceUnits |
This is used only to interpret the shape's true physical size. | |
double | scaleX = 1.0 |
Internal horizontal scale of the region. | |
double | scaleY = 1.0 |
Internal vertical scale of the region. |
Also, a region can be INPUT(REALTIME|BATCH), OUTPUT(REALTIME|INTERMITTENT), or STATIC. This is entirely determined by the type(s) of attachments (input event handlers, input filters, realtime outputs, print output) you add to a region. If you do not add anything, it is by default a STATIC region. For example, if you add an input event handler for a streaming pen, it becomes an INPUT(REALTIME) region. Regions that handle interactive input will automatically be overlaid with pattern when rendered to PDF or to a printer.
Regardless of whether the Shape is closed or not, we assume that all regions are closed Shapes. A rectangular region is represented using this class's Region(4 args) constructors.
This software is distributed under the BSD License.
Definition at line 42 of file Region.java.
Region | ( | String | name, | |
double | xInches, | |||
double | yInches, | |||
double | wInches, | |||
double | hInches | |||
) |
For our American friends.
xInches | ||
yInches | ||
wInches | ||
hInches |
Definition at line 139 of file Region.java.
name | ||
s | the shape that defines this region. | |
u | the reference unit for interpreting the shape's coordinates |
Definition at line 151 of file Region.java.
References Region.referenceUnits.
A protected constructor so subclasses can assign the shape whichever way they please.
A Region doesn't really make sense without a shape, so use this constructor carefully (i.e., make sure to assign a sensible shape).
u |
Definition at line 164 of file Region.java.
References Region.referenceUnits.
We will convert all the units to x's type.
Thus, if you pass in an Inch, Centimeter, Foot, Points, we will convert everything to Inches. It's OK to keep the x object around, because we only use it to interpret the shape object.
x | ||
y | ||
w | ||
h |
Definition at line 179 of file Region.java.
References Units.getValue(), and Units.getValueIn().
void addEventHandler | ( | EventHandler | handler | ) |
Keeps track of this event handler.
The PaperToolkit will dispatch events to these, whenever the event deals with this region.
A particular kind of event handler can be thought of as a "content filter," which will grab input and "change" the meaning of the input in some way. The canonical example is the HandwritingRecognizer, as it will collect ink and then change it into ASCII text.
handler |
Definition at line 194 of file Region.java.
References EventHandler.addParentRegion().
Referenced by ButtonRegion.ButtonRegion(), and RegionComponent.RegionComponent().
List<EventHandler> getEventHandlers | ( | ) |
Definition at line 208 of file Region.java.
Referenced by EventEngine.handlePenEvent(), and SheetFrame.SheetFrame().
Color getFillColor | ( | ) |
Units getHeight | ( | ) |
Definition at line 222 of file Region.java.
References Units.getUnitsObjectOfSameTypeWithValue(), Region.referenceUnits, and Region.scaleY.
Referenced by FlexiblePatternCoordinateConverter.FlexiblePatternCoordinateConverter(), RegionID.RegionID(), TextRenderer.renderToG2D(), SheetFrame.SheetFrame(), and SketchToPaperUI.translate().
String getIsActiveString | ( | ) |
Definition at line 230 of file Region.java.
References Region.isActive().
Referenced by Region.toString().
String getName | ( | ) |
Definition at line 237 of file Region.java.
Referenced by Sheet.addRegion(), PatternLocationToSheetLocationMapping.getPatternBoundsOfRegion(), FlexiblePatternCoordinateConverter.getRegionName(), RegionID.RegionID(), PatternLocationToSheetLocationMapping.setPatternInformationOfRegion(), SheetFrame.SheetFrame(), Region.toString(), and DebuggingEnvironment.visualize().
double getOpacity | ( | ) |
Definition at line 245 of file Region.java.
Referenced by RegionRenderer.renderToG2D().
Units getOriginX | ( | ) |
Definition at line 252 of file Region.java.
References Units.getUnitsObjectOfSameTypeWithValue(), and Region.referenceUnits.
Referenced by RegionID.RegionID(), CompoundRenderer.renderToG2D(), SheetFrame.SheetFrame(), and CompoundRegion.toString().
Units getOriginY | ( | ) |
Definition at line 259 of file Region.java.
References Units.getUnitsObjectOfSameTypeWithValue(), and Region.referenceUnits.
Referenced by RegionID.RegionID(), CompoundRenderer.renderToG2D(), SheetFrame.SheetFrame(), and CompoundRegion.toString().
RegionRenderer getRenderer | ( | ) |
Subclasses should override this, to customize rendering.
Otherwise, you'll just get gray boxes, which is what RegionRenderer does.
Reimplemented in CompoundRegion, ImageRegion, PolygonalRegion, and TextRegion.
Definition at line 273 of file Region.java.
double getScaleX | ( | ) |
Definition at line 285 of file Region.java.
References Region.scaleX.
Referenced by CompoundRegion.addChild(), RegionGroup.addRegion(), RegionRenderer.renderToG2D(), PolygonRenderer.renderToG2D(), ImageRenderer.renderToG2D(), and PolygonalRegion.toString().
double getScaleY | ( | ) |
Definition at line 292 of file Region.java.
References Region.scaleY.
Referenced by CompoundRegion.addChild(), RegionGroup.addRegion(), RegionRenderer.renderToG2D(), PolygonRenderer.renderToG2D(), ImageRenderer.renderToG2D(), and PolygonalRegion.toString().
Shape getShape | ( | ) |
Subclasses can modify the internal shape object.
Definition at line 301 of file Region.java.
Referenced by CompoundRegion.addChild(), RegionGroup.addRegion(), PolygonalRegion.getPolygonReference(), PolygonRenderer.renderToG2D(), and CompoundRegion.toString().
Units getUnits | ( | ) |
TODO: We should make sure that Units objects immutable if possible.
Definition at line 314 of file Region.java.
References Region.referenceUnits.
Referenced by CompoundRegion.addChild(), RegionGroup.addRegion(), ImageRegion.ImageRegion(), RegionRenderer.renderToG2D(), PolygonRenderer.renderToG2D(), ImageRenderer.renderToG2D(), PolygonalRegion.toString(), and ImageRegion.toString().
Rectangle2D getUnscaledBounds2D | ( | ) |
Definition at line 321 of file Region.java.
Referenced by RegionRenderer.renderToG2D().
Units getUnscaledBoundsHeight | ( | ) |
Definition at line 328 of file Region.java.
References Units.getUnitsObjectOfSameTypeWithValue(), and Region.referenceUnits.
Units getUnscaledBoundsWidth | ( | ) |
Definition at line 335 of file Region.java.
References Units.getUnitsObjectOfSameTypeWithValue(), and Region.referenceUnits.
Shape getUnscaledShapeCopy | ( | ) |
Definition at line 343 of file Region.java.
Units getWidth | ( | ) |
Definition at line 350 of file Region.java.
References Units.getUnitsObjectOfSameTypeWithValue(), Region.referenceUnits, and Region.scaleX.
Referenced by FlexiblePatternCoordinateConverter.FlexiblePatternCoordinateConverter(), RegionID.RegionID(), TextRenderer.renderToG2D(), SheetFrame.SheetFrame(), and SketchToPaperUI.translate().
boolean isActive | ( | ) |
Definition at line 359 of file Region.java.
Referenced by Region.getIsActiveString().
boolean isVisible | ( | ) |
Definition at line 366 of file Region.java.
void scaleRegion | ( | double | sX, | |
double | sY | |||
) |
Scales the points in the current region by a horizontal and vertical multiplier.
sX | ||
sY |
Definition at line 403 of file Region.java.
References Region.scaleX, and Region.scaleY.
Referenced by Region.scaleRegionUniformly().
void scaleRegionUniformly | ( | double | scale | ) |
Resizes the region uniformly in x and y.
We actually just store the number and scale it whenever we need to render the final region. The Lazy Approach. =) This is nice because we can scale the region multiple times without getting aliasing effects.
scale |
Definition at line 415 of file Region.java.
References Region.scaleRegion().
void setActive | ( | boolean | isRegionActive | ) |
isRegionActive | determines whether this will be an active region or not |
Definition at line 423 of file Region.java.
void setFillColor | ( | Color | theFillColor | ) |
void setName | ( | String | theName | ) |
theName | the name of the region. Name it something useful, like "Blue Button for Changing Pen Colors" |
Definition at line 439 of file Region.java.
Referenced by ImageRegion.ImageRegion().
void setOpacity | ( | double | theOpacityFrom0To1 | ) |
theOpacityFrom0To1 | bounds checked from 0.0 to 1.0 |
Definition at line 447 of file Region.java.
void setParentSheet | ( | Sheet | sheet | ) |
For traversing up the UI hierarchy, in Event Visualizations.
sheet |
Definition at line 461 of file Region.java.
Referenced by Sheet.addRegion().
void setScale | ( | double | newScaleX, | |
double | newScaleY | |||
) |
Replaces the scaling factors.
newScaleX | ||
newScaleY |
Definition at line 471 of file Region.java.
References Region.scaleX, and Region.scaleY.
Referenced by Region.resetScale().
void setShape | ( | Shape | s | ) | [protected] |
Subclasses can use this method to set the shape after constructing the object.
s |
Definition at line 481 of file Region.java.
Referenced by CompoundRegion.addChild(), ImageRegion.ImageRegion(), and TextRegion.TextRegion().
void setVisible | ( | boolean | v | ) |
String toString | ( | ) |
Please override for more interesting output.
This will print the name of the class along with all the segments of the shape.
Reimplemented in CompoundRegion, ImageRegion, PolygonalRegion, and TextRegion.
Definition at line 504 of file Region.java.
References Region.getIsActiveString(), Region.getName(), Units.getUnitName(), Region.referenceUnits, Region.scaleX, and Region.scaleY.
Referenced by RegionRenderer.renderToG2D().
Units referenceUnits [protected] |
This is used only to interpret the shape's true physical size.
The value of the units object doesn't matter. Only the type of the unit matters.
Definition at line 97 of file Region.java.
Referenced by Region.getHeight(), Region.getOriginX(), Region.getOriginY(), Region.getUnits(), Region.getUnscaledBoundsHeight(), Region.getUnscaledBoundsWidth(), Region.getWidth(), Region.Region(), TextRegion.TextRegion(), TextRegion.toString(), Region.toString(), and CompoundRegion.toString().
double scaleX = 1.0 [protected] |
Internal horizontal scale of the region.
When rendering, we will multiply the shape by this scale. This is only a RECOMMENDATION and not a requirement of the renderer, however, as some regions may not make sense if scaled after the fact. However, we will try to make sure most of our calculations respect this scaling factor.
Definition at line 105 of file Region.java.
Referenced by Region.getScaleX(), Region.getWidth(), ImageRegion.getWidthVal(), Region.scaleRegion(), Region.setScale(), and Region.toString().
double scaleY = 1.0 [protected] |
Internal vertical scale of the region.
When rendering, we will multiply the shape by this scale.
Definition at line 111 of file Region.java.
Referenced by Region.getHeight(), ImageRegion.getHeightVal(), Region.getScaleY(), Region.scaleRegion(), Region.setScale(), and Region.toString().