コード例 #1
0
 public ImmutablePoint getScaledOffset(int boxSize) {
   ImmutablePoint point = offset;
   if (order > 0) {
     point = point.translate(10 * order, 0);
   }
   return point.scale(getSquareSize(), boxSize);
 }
コード例 #2
0
  // TODO misleading name - is centered around point and scaled font but not scale center point
  // (probably :)
  public void drawAntialiasedTextCenteredNoScale(
      Graphics2D g2,
      String text,
      int fontSize,
      Position pos,
      ImmutablePoint center,
      Color fgColor,
      Color bgColor) {
    Color original = g2.getColor();
    FontRenderContext frc = g2.getFontRenderContext();
    TextLayout tl = new TextLayout(text, getFont(fontSize), frc);
    Rectangle2D bounds = tl.getBounds();

    center = center.translate((int) (bounds.getWidth() / -2), (int) (bounds.getHeight() / -2));

    if (bgColor != null) {
      g2.setColor(bgColor);
      g2.fillRect(
          getOffsetX(pos) + center.getX() - 6,
          getOffsetY(pos) + center.getY() - 5,
          12 + (int) bounds.getWidth(),
          10 + (int) bounds.getHeight());
    }

    g2.setColor(fgColor);
    tl.draw(
        g2,
        getOffsetX(pos) + center.getX(),
        getOffsetY(pos) + center.getY() + (int) bounds.getHeight());
    g2.setColor(original);
  }