Codota Logo
AttributeKeys
Code IndexAdd Codota to your IDE (free)

How to use
AttributeKeys
in
org.jhotdraw.draw

Best Java code snippets using org.jhotdraw.draw.AttributeKeys (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Connection c =
  • Codota IconDataSource dataSource;dataSource.getConnection()
  • Codota IconString url;DriverManager.getConnection(url)
  • Codota IconIdentityDatabaseUtil.getDBConnection()
  • Smart code suggestions by Codota
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

  /**
   * Returns the distance, that a Rectangle needs to grow (or shrink) to
   * make hit detections on a shape as specified by the FILL_UNDER_STROKE and STROKE_POSITION
   * attributes of a figure.
   * The value returned is the number of units that need to be grown (or shrunk)
   * perpendicular to a stroke on an outline of the shape.
   */
  public static double getPerpendicularHitGrowth(Figure f) {
    double grow;
    if (f.get(STROKE_COLOR) == null) {
      grow = getPerpendicularFillGrowth(f);
    } else {
      double strokeWidth = AttributeKeys.getStrokeTotalWidth(f);
      grow = getPerpendicularDrawGrowth(f) + strokeWidth / 2d;
    }
    return grow;
  }
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public Rectangle2D.Double getDrawingArea() {
  Rectangle2D.Double r = (Rectangle2D.Double) roundrect.getBounds2D();
  double grow = AttributeKeys.getPerpendicularHitGrowth(this) + 1;
  Geom.grow(r, grow, grow);
  return r;
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public Font getFont() {
  return AttributeKeys.getFont(this);
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
protected void drawFill(Graphics2D g) {
  Shape triangle = getBezierPath();
  double grow = AttributeKeys.getPerpendicularFillGrowth(this);
  if (grow != 0d) {
    GrowStroke gs = new GrowStroke((float) grow,
        (float) (AttributeKeys.getStrokeTotalWidth(this) *
        get(STROKE_MITER_LIMIT))
        );
    triangle = gs.createStrokedShape(triangle);
  }
  
  g.fill(triangle);
}

origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
protected void drawStroke(Graphics2D g) {
  Shape triangle = getBezierPath();
  
  double grow = AttributeKeys.getPerpendicularDrawGrowth(this);
  if (grow != 0d) {
    GrowStroke gs = new GrowStroke((float) grow,
        (float) (AttributeKeys.getStrokeTotalWidth(this) *
        get(STROKE_MITER_LIMIT))
        );
    triangle = gs.createStrokedShape(triangle);
  }
  
  g.draw(triangle);
}
@Override
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

public Point2D.Double chop(Point2D.Double p) {
  Shape triangle = getBezierPath();
  
  double grow = AttributeKeys.getPerpendicularHitGrowth(this);
  if (grow != 0d) {
    GrowStroke gs = new GrowStroke((float) grow,
        (float) (AttributeKeys.getStrokeTotalWidth(this) *
        get(STROKE_MITER_LIMIT))
        );
    triangle =gs.createStrokedShape(triangle);
  }
  return Geom.chop(triangle, p);
}
/**
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
protected void drawFill(Graphics2D g) {
  Ellipse2D.Double r = (Ellipse2D.Double) ellipse.clone();
  double grow = AttributeKeys.getPerpendicularFillGrowth(this);
  r.x -= grow;
  r.y -= grow;
  r.width += grow * 2;
  r.height += grow * 2;
  if (r.width > 0 && r.height > 0) {
    g.fill(r);
  }
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
protected void drawStroke(Graphics2D g) {
  Ellipse2D.Double r = (Ellipse2D.Double) ellipse.clone();
  double grow = AttributeKeys.getPerpendicularDrawGrowth(this);
  r.x -= grow;
  r.y -= grow;
  r.width += grow * 2;
  r.height += grow * 2;
  if (r.width > 0 && r.height > 0) {
    g.draw(r);
  }
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public boolean contains(Point2D.Double p) {
  return Geom.lineContainsPoint(
      line.x1, line.y1,
      line.x2, line.y2,
      p.x, p.y,
      AttributeKeys.getStrokeTotalWidth(this));
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

public Stroke getStroke() {
  return AttributeKeys.getStroke(this);
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

float miterLimit = (float) getStrokeTotalMiterLimit(f);
double dashFactor = f.get(IS_STROKE_DASH_FACTOR) ? strokeWidth : 1d;
switch (f.get(STROKE_TYPE)) {
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Nullable public static Font getFont(Figure f) {
  Font prototype = f.get(FONT_FACE);
  if (prototype == null) {
    return null;
  }
  if (getFontStyle(f) != Font.PLAIN) {
    return prototype.deriveFont(getFontStyle(f), f.get(FONT_SIZE).floatValue());
  } else {
    return prototype.deriveFont(f.get(FONT_SIZE).floatValue());
  }
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Checks if a Point2D.Double is inside the figure.
 */
@Override
public boolean contains(Point2D.Double p) {
  Shape triangle = getBezierPath();
  
  double grow = AttributeKeys.getPerpendicularHitGrowth(this);
  if (grow != 0d) {
    GrowStroke gs = new GrowStroke((float) grow,
        (float) (AttributeKeys.getStrokeTotalWidth(this) *
        get(STROKE_MITER_LIMIT))
        );
    triangle =gs.createStrokedShape(triangle);
  }
  return triangle.contains(p);
}
@Override
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
protected void drawFill(Graphics2D g) {
  RoundRectangle2D.Double r = (RoundRectangle2D.Double) roundrect.clone();
  double grow = AttributeKeys.getPerpendicularFillGrowth(this);
  r.x -= grow;
  r.y -= grow;
  r.width += grow * 2;
  r.height += grow * 2;
  r.arcwidth += grow * 2;
  r.archeight += grow * 2;
  if (r.width > 0 && r.height > 0) {
    g.fill(r);
  }
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
protected void drawStroke(Graphics2D g) {
  RoundRectangle2D.Double r = (RoundRectangle2D.Double) roundrect.clone();
  double grow = AttributeKeys.getPerpendicularDrawGrowth(this);
  r.x -= grow;
  r.y -= grow;
  r.width += grow * 2;
  r.height += grow * 2;
  r.arcwidth += grow * 2;
  r.archeight += grow * 2;
  if (r.width > 0 && r.height > 0) {
    g.draw(r);
  }
}
// SHAPE AND BOUNDS
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
protected void drawFill(Graphics2D g) {
  if (isClosed() || get(UNCLOSED_PATH_FILLED)) {
    double grow = AttributeKeys.getPerpendicularFillGrowth(this);
    if (grow == 0d) {
      g.fill(path);
    } else {
      GrowStroke gs = new GrowStroke(grow,
          AttributeKeys.getStrokeTotalWidth(this)
          * get(STROKE_MITER_LIMIT));
      g.fill(gs.createStrokedShape(path));
    }
  }
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
protected void drawStroke(Graphics2D g) {
  if (isClosed()) {
    double grow = AttributeKeys.getPerpendicularDrawGrowth(this);
    if (grow == 0d) {
      g.draw(path);
    } else {
      GrowStroke gs = new GrowStroke(grow,
          AttributeKeys.getStrokeTotalWidth(this)
          * get(STROKE_MITER_LIMIT));
      g.draw(gs.createStrokedShape(path));
    }
  } else {
    g.draw(getCappedPath());
  }
  drawCaps(g);
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Returns the distance, that a Rectangle needs to grow (or shrink) to
 * draw (aka stroke) its shape as specified by the FILL_UNDER_STROKE and 
 * STROKE_POSITION attributes of a figure.
 * The value returned is the number of units that need to be grown (or shrunk)
 * perpendicular to a stroke on an outline of the shape.
 */
public static double getPerpendicularDrawGrowth(Figure f) {
  double grow;
  double strokeWidth = AttributeKeys.getStrokeTotalWidth(f);
  switch (f.get(STROKE_PLACEMENT)) {
    case INSIDE:
      grow = strokeWidth / -2d;
      break;
    case OUTSIDE:
      grow = strokeWidth / 2d;
      break;
    case CENTER:
    default:
      grow = 0f;
      break;
  }
  return grow;
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

public Stroke getStroke() {
  return AttributeKeys.getStroke(this);
}

origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

public static Stroke getStroke(Figure f) {
  double strokeWidth = f.get(STROKE_WIDTH);
  float miterLimit = (float) getStrokeTotalMiterLimit(f);
  double dashFactor = f.get(IS_STROKE_DASH_FACTOR) ? strokeWidth : 1d;
  double dashPhase = f.get(STROKE_DASH_PHASE);
org.jhotdraw.drawAttributeKeys

Javadoc

Defines a put of well known Figure attributes.

If you are developing an applications that uses a different put or an extended put of attributes, it is recommended to create a new AttributeKeys class, and to define all needed AttributeKeys as static variables in there.

Most used methods

  • getPerpendicularDrawGrowth
    Returns the distance, that a Rectangle needs to grow (or shrink) to draw (aka stroke) its shape as s
  • getPerpendicularFillGrowth
    Returns the distance, that a Rectangle needs to grow (or shrink) to fill its shape as specified by t
  • getPerpendicularHitGrowth
    Returns the distance, that a Rectangle needs to grow (or shrink) to make hit detections on a shape a
  • getFont
  • getFontStyle
  • getStroke
  • getStrokeTotalMiterLimit
    Convenience method for computing the total stroke miter limit from the STROKE_MITER_LIMIT, and IS_ST
  • getStrokeTotalWidth
    Convenience method for computing the total stroke width from the STROKE_WIDTH, STROKE_INNER_WIDTH an

Popular in Java

  • Creating JSON documents from java classes using gson
  • startActivity (Activity)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • getContentResolver (Context)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • DataSource (javax.sql)
    A factory for connections to the physical data source that this DataSource object represents. An alt
  • JLabel (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now