use of java.awt.geom.GeneralPath in project openblocks by mikaelhg.
the class CIconButton method getIconShape.
/**
* This methods maps an icon Enum to an icon Shape
*
* @param icon - icon enum
*
* @requires none
* @return the cooresponding icon shape (to match the icon enum)
* or null if the icon enum does not match any known ones.
*/
private Shape getIconShape(Icon icon) {
int width = this.getWidth() - 2 * ICON_INSET;
if (icon == Icon.PLAY) {
GeneralPath shape = new GeneralPath();
shape.moveTo(ICON_INSET, ICON_INSET);
shape.lineTo(ICON_INSET + width, ICON_INSET + width / 2);
shape.lineTo(ICON_INSET, ICON_INSET + width);
shape.lineTo(ICON_INSET, ICON_INSET);
shape.closePath();
return shape;
} else if (icon == Icon.PAUSE) {
Rectangle2D.Float rect1 = new Rectangle2D.Float(ICON_INSET, ICON_INSET, width / 3, width);
Rectangle2D.Float rect2 = new Rectangle2D.Float(ICON_INSET + width * 2 / 3, ICON_INSET, width / 3, width);
Area shape1 = new Area(rect1);
Area shape2 = new Area(rect2);
shape1.add(shape2);
return shape1;
} else if (icon == Icon.STEP) {
Rectangle2D.Float rect = new Rectangle2D.Float(ICON_INSET, ICON_INSET, width / 5, width);
GeneralPath triangle = new GeneralPath();
triangle.moveTo(ICON_INSET + width * 2 / 5, ICON_INSET);
triangle.lineTo(ICON_INSET + width, ICON_INSET + width / 2);
triangle.lineTo(ICON_INSET + width * 2 / 5, ICON_INSET + width);
triangle.closePath();
Area area1 = new Area(rect);
Area area2 = new Area(triangle);
area1.add(area2);
return area1;
} else if (icon == Icon.STOP) {
Rectangle2D.Float rect1 = new Rectangle2D.Float(ICON_INSET, ICON_INSET, width, width);
Area shape1 = new Area(rect1);
return shape1;
}
return null;
}
use of java.awt.geom.GeneralPath in project openblocks by mikaelhg.
the class SliderBlueprint method reformTrailingTrack.
/**
* creates the shape of the track on the right side of the thumb
* @param blueprint
* @return general path shape of the track on the right side of the thumb
*/
public Shape reformTrailingTrack(SliderBlueprint blueprint) {
GeneralPath shape = new GeneralPath();
shape.moveTo(blueprint.thumbCenter, blueprint.trackTop);
shape.lineTo(blueprint.closeTrackEdgeRight, blueprint.trackTop);
shape.curveTo(blueprint.farTrackEdgeRight, blueprint.trackTop, blueprint.farTrackEdgeRight, blueprint.trackBottom, blueprint.closeTrackEdgeRight, blueprint.trackBottom);
shape.lineTo(blueprint.thumbCenter, blueprint.trackBottom);
shape.lineTo(blueprint.thumbCenter, blueprint.trackTop);
shape.closePath();
return shape;
}
use of java.awt.geom.GeneralPath in project openblocks by mikaelhg.
the class CTextField method getXCross.
private Shape getXCross(int w, int h) {
GeneralPath shape = new GeneralPath();
shape.moveTo(w - h * 2 / 3, h / 3);
shape.lineTo(w - h / 3, h * 2 / 3);
shape.moveTo(w - h / 3, h / 3);
shape.lineTo(w - h * 2 / 3, h * 2 / 3);
return shape;
}
use of java.awt.geom.GeneralPath in project openblocks by mikaelhg.
the class Comment method reformComment.
/**
* Recalculate the shape of this comment
*/
public void reformComment() {
int w = textArea.isEditable() ? (int) (this.width * zoom) : (int) (Comment.MINIMUM_WIDTH * zoom);
int h = textArea.isEditable() ? (int) (this.height * zoom) : (int) (Comment.MINIMUM_HEIGHT * zoom);
int m = (int) (this.margin * zoom);
GeneralPath path2 = new GeneralPath();
path2.moveTo(m - 1, m - 1);
path2.lineTo(w - m, m - 1);
path2.lineTo(w - m, h - m);
path2.lineTo(m - 1, h - m);
path2.closePath();
textarea = path2;
body = new RoundRectangle2D.Double(0, 0, w - 1, h - 1, 3 * m, 3 * m);
GeneralPath path3 = new GeneralPath();
path3.moveTo(w - 3 * m, h);
path3.lineTo(w, h - 3 * m);
path3.curveTo(w, h, w, h, w - 3 * m, h);
resize = path3;
scrollPane.setBounds(m, m, w - 2 * m, h - 2 * m);
scrollPane.setThumbWidth(textArea.isEditable() ? 2 * m : 0);
this.setBounds(this.getX(), this.getY(), w, h);
this.revalidate();
this.repaint();
if (arrow != null) {
arrow.updateArrow();
}
}
use of java.awt.geom.GeneralPath in project processing by processing.
the class PdeTextAreaPainter method drawRightArrow.
private static void drawRightArrow(Graphics g, float x, float y, float w, float h) {
Graphics2D g2 = (Graphics2D) g;
GeneralPath path = new GeneralPath();
path.moveTo(x, y);
path.lineTo(x + w, y + h / 2);
path.lineTo(x, y + h);
path.closePath();
g2.fill(path);
}
Aggregations