當前位置: 首頁>>代碼示例>>Java>>正文


Java GeneralPath.transform方法代碼示例

本文整理匯總了Java中java.awt.geom.GeneralPath.transform方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneralPath.transform方法的具體用法?Java GeneralPath.transform怎麽用?Java GeneralPath.transform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.geom.GeneralPath的用法示例。


在下文中一共展示了GeneralPath.transform方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: transformTriangle

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
 * Flip or rotate a left triangle so that it fits another side.
 *
 * @param triangle The left triangle.
 * @return The transformed triangle.
 */
private GeneralPath transformTriangle(GeneralPath triangle) {
    switch(unionPosition) {
    case TOP:
        triangle.transform(AffineTransform.getQuadrantRotateInstance(1));
        triangle.transform(AffineTransform.getTranslateInstance(WIDTH, 0));
        break;
    case BOTTOM:
        triangle.transform(AffineTransform.getQuadrantRotateInstance(3));
        triangle.transform(AffineTransform.getTranslateInstance(0, HEIGHT));
        break;
    case RIGHT:
        triangle.transform(AffineTransform.getScaleInstance(-1, 1));
        triangle.transform(AffineTransform.getTranslateInstance(WIDTH, 0));
        break;
    case LEFT:
    default:
    }
    return triangle;
}
 
開發者ID:wintertime,項目名稱:FreeCol,代碼行數:26,代碼來源:Flag.java

示例2: getGlyphOutlineBounds

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
Rectangle2D getGlyphOutlineBounds(int glyphID, float x, float y) {
    Rectangle2D result = null;
    if (sgv.invdtx == null) {
        result = new Rectangle2D.Float();
        result.setRect(strike.getGlyphOutlineBounds(glyphID)); // don't mutate cached rect
    } else {
        GeneralPath gp = strike.getGlyphOutline(glyphID, 0, 0);
        gp.transform(sgv.invdtx);
        result = gp.getBounds2D();
    }
    /* Since x is the logical advance of the glyph to this point.
     * Because of the way that Rectangle.union is specified, this
     * means that subsequent unioning of a rect including that
     * will be affected, even if the glyph is empty. So skip such
     * cases. This alone isn't a complete solution since x==0
     * may also not be what is wanted. The code that does the
     * unioning also needs to be aware to ignore empty glyphs.
     */
    if (!result.isEmpty()) {
        result.setRect(result.getMinX() + x + dx,
                       result.getMinY() + y + dy,
                       result.getWidth(), result.getHeight());
    }
    return result;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:26,代碼來源:StandardGlyphVector.java

示例3: transformBend

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
 * Flip or rotate a top left triangle so that it fits another
 * corner.
 *
 * @param triangle The top left triangle.
 * @return The transformed triangle.
 */
private GeneralPath transformBend(GeneralPath triangle) {
    if (unionPosition == UnionPosition.TOP) {
        if (decoration == Decoration.BEND) {
            triangle.transform(AffineTransform.getScaleInstance(-1, 1));
            triangle.transform(AffineTransform.getTranslateInstance(WIDTH, 0));
        } else if (decoration == Decoration.BEND_SINISTER) {
            // nothing to do: default is top left
        }
    } else if (unionPosition == UnionPosition.BOTTOM) {
        if (decoration == Decoration.BEND) {
            triangle.transform(AffineTransform.getScaleInstance(1, -1));
            triangle.transform(AffineTransform.getTranslateInstance(0, HEIGHT));
        } else if (decoration == Decoration.BEND_SINISTER) {
            triangle.transform(AffineTransform.getQuadrantRotateInstance(2));
            triangle.transform(AffineTransform.getTranslateInstance(WIDTH, HEIGHT));
        }
    }
    return triangle;
}
 
開發者ID:wintertime,項目名稱:FreeCol,代碼行數:27,代碼來源:Flag.java

示例4: drawNeedle

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
 * Draws the needle.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param rotate  the rotation point.
 * @param angle  the angle.
 */
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, Point2D rotate, double angle) {

    GeneralPath shape = new GeneralPath();
    shape.append(new Arc2D.Double(-9.0, -7.0, 10,
                                  14, 0.0, 25.5,  Arc2D.OPEN), true);
    shape.append(new Arc2D.Double(0.0, -7.0, 10,
                                  14, 154.5, 25.5,  Arc2D.OPEN), true);
    shape.closePath();
    getTransform().setToTranslation(plotArea.getMinX(), plotArea.getMaxY());
    getTransform().scale(plotArea.getWidth(), plotArea.getHeight() / 3);
    shape.transform(getTransform());

    if ((rotate != null) && (angle != 0)) {
        /// we have rotation
        getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
        shape.transform(getTransform());
    }

    defaultDisplay(g2, shape);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:29,代碼來源:ShipNeedle.java

示例5: drawNeedle

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
 * Draws the needle.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param rotate  the rotation point.
 * @param angle  the angle.
 */
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, 
                          Point2D rotate, double angle) {

    GeneralPath shape = new GeneralPath();
    shape.append(new Arc2D.Double(-9.0, -7.0, 10, 14, 0.0, 25.5, 
            Arc2D.OPEN), true);
    shape.append(new Arc2D.Double(0.0, -7.0, 10, 14, 154.5, 25.5, 
            Arc2D.OPEN), true);
    shape.closePath();
    getTransform().setToTranslation(plotArea.getMinX(), plotArea.getMaxY());
    getTransform().scale(plotArea.getWidth(), plotArea.getHeight() / 3);
    shape.transform(getTransform());

    if ((rotate != null) && (angle != 0)) {
        /// we have rotation
        getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
        shape.transform(getTransform());
    }

    defaultDisplay(g2, shape);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:30,代碼來源:ShipNeedle.java

示例6: getOutline

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
public Shape getOutline(AffineTransform tx) {

        GeneralPath dstShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);

        for (int i=0, n = 0; i < fComponents.length; i++, n += 2) {
            TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];

            dstShape.append(tlc.getOutline(locs[n], locs[n+1]), false);
        }

        if (tx != null) {
            dstShape.transform(tx);
        }
        return dstShape;
    }
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:16,代碼來源:TextLine.java

示例7: appendGlyphOutline

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
void appendGlyphOutline(int glyphID, GeneralPath result, float x, float y) {
    // !!! fontStrike needs a method for this.  For that matter, GeneralPath does.
    GeneralPath gp = null;
    if (sgv.invdtx == null) {
        gp = strike.getGlyphOutline(glyphID, x + dx, y + dy);
    } else {
        gp = strike.getGlyphOutline(glyphID, 0, 0);
        gp.transform(sgv.invdtx);
        gp.transform(AffineTransform.getTranslateInstance(x + dx, y + dy));
    }
    PathIterator iterator = gp.getPathIterator(null);
    result.append(iterator, false);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:14,代碼來源:StandardGlyphVector.java

示例8: getIcon

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
 * Returns an icon.
 *
 * @param shape  the shape.
 * @param fill  the fill flag.
 * @param outline  the outline flag.
 *
 * @return the icon.
 */
private Icon getIcon(Shape shape, final boolean fill, final boolean outline) {
    final int width = shape.getBounds().width;
    final int height = shape.getBounds().height;
    final GeneralPath path = new GeneralPath(shape);
    return new Icon() {
        public void paintIcon(Component c, Graphics g, int x, int y) {
            Graphics2D g2 = (Graphics2D) g;
            path.transform(AffineTransform.getTranslateInstance(x, y));
            if (fill) {
                g2.fill(path);
            }
            if (outline) {
                g2.draw(path);
            }
            path.transform(AffineTransform.getTranslateInstance(-x, -y));
        }

        public int getIconWidth() {
            return width;
        }

        public int getIconHeight() {
            return height;
        }
    };
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:36,代碼來源:MinMaxCategoryRenderer.java

示例9: getIcon

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
 * Returns an icon.
 *
 * @param shape  the shape.
 * @param fillPaint  the fill paint.
 * @param outlinePaint  the outline paint.
 *
 * @return The icon.
 */
private Icon getIcon(Shape shape, final Paint fillPaint, 
                    final Paint outlinePaint) {

  final int width = shape.getBounds().width;
  final int height = shape.getBounds().height;
  final GeneralPath path = new GeneralPath(shape);
  return new Icon() {
      public void paintIcon(Component c, Graphics g, int x, int y) {
          Graphics2D g2 = (Graphics2D) g;
          path.transform(AffineTransform.getTranslateInstance(x, y));
          if (fillPaint != null) {
              g2.setPaint(fillPaint);
              g2.fill(path);
          }
          if (outlinePaint != null) {
              g2.setPaint(outlinePaint);
              g2.draw(path);
          }
          path.transform(AffineTransform.getTranslateInstance(-x, -y));
    }

    public int getIconWidth() {
        return width;
    }

    public int getIconHeight() {
        return height;
    }

  };
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:41,代碼來源:MinMaxCategoryRenderer.java

示例10: drawNeedle

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
 * Draws the needle.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param rotate  the rotation point.
 * @param angle  the angle.
 */
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, Point2D rotate, double angle) {

    GeneralPath shape1 = new GeneralPath();
    GeneralPath shape2 = new GeneralPath();
    float minX = (float) plotArea.getMinX();
    float minY = (float) plotArea.getMinY();
    float maxX = (float) plotArea.getMaxX();
    float maxY = (float) plotArea.getMaxY();
    float midX = (float) (minX + (plotArea.getWidth() / 2));
    float midY = (float) (minY + (plotArea.getHeight() / 2));

    shape1.moveTo(minX, midY);
    shape1.lineTo(midX, minY);
    shape1.lineTo(maxX, midY);
    shape1.closePath();

    shape2.moveTo(minX, midY);
    shape2.lineTo(midX, maxY);
    shape2.lineTo(maxX, midY);
    shape2.closePath();

    if ((rotate != null) && (angle != 0)) {
        /// we have rotation huston, please spin me
        getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
        shape1.transform(getTransform());
        shape2.transform(getTransform());
    }

    if (getFillPaint() != null) {
        g2.setPaint(getFillPaint());
        g2.fill(shape1);
    }

    if (getHighlightPaint() != null) {
        g2.setPaint(getHighlightPaint());
        g2.fill(shape2);
    }

    if (getOutlinePaint() != null) {
        g2.setStroke(getOutlineStroke());
        g2.setPaint(getOutlinePaint());
        g2.draw(shape1);
        g2.draw(shape2);
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:54,代碼來源:PointerNeedle.java

示例11: drawNeedle

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
 * Draws the needle.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param rotate  the rotation point.
 * @param angle  the angle.
 */
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, 
                          Point2D rotate, double angle) {

    GeneralPath shape1 = new GeneralPath();
    GeneralPath shape2 = new GeneralPath();
    float minX = (float) plotArea.getMinX();
    float minY = (float) plotArea.getMinY();
    float maxX = (float) plotArea.getMaxX();
    float maxY = (float) plotArea.getMaxY();
    float midX = (float) (minX + (plotArea.getWidth() / 2));
    float midY = (float) (minY + (plotArea.getHeight() / 2));

    shape1.moveTo(minX, midY);
    shape1.lineTo(midX, minY);
    shape1.lineTo(maxX, midY);
    shape1.closePath();

    shape2.moveTo(minX, midY);
    shape2.lineTo(midX, maxY);
    shape2.lineTo(maxX, midY);
    shape2.closePath();

    if ((rotate != null) && (angle != 0)) {
        /// we have rotation huston, please spin me
        getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
        shape1.transform(getTransform());
        shape2.transform(getTransform());
    }

    if (getFillPaint() != null) {
        g2.setPaint(getFillPaint());
        g2.fill(shape1);
    }

    if (getHighlightPaint() != null) {
        g2.setPaint(getHighlightPaint());
        g2.fill(shape2);
    }

    if (getOutlinePaint() != null) {
        g2.setStroke(getOutlineStroke());
        g2.setPaint(getOutlinePaint());
        g2.draw(shape1);
        g2.draw(shape2);
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:55,代碼來源:PointerNeedle.java

示例12: center

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
 * Centers the given path on the given point (x,y).
 *
 * @param path The path to center.
 * @param x The x coordinate of the center.
 * @param y The y coordinate of the center.
 */
private void center(GeneralPath path, double x, double y) {
    double dx = x - path.getBounds().getX() - path.getBounds().getWidth() / 2;
    double dy = y - path.getBounds().getY() - path.getBounds().getHeight() / 2;
    path.transform(AffineTransform.getTranslateInstance(dx, dy));
}
 
開發者ID:wintertime,項目名稱:FreeCol,代碼行數:13,代碼來源:Flag.java


注:本文中的java.awt.geom.GeneralPath.transform方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。