Java Graphics创建样式

时间:2017-02-27 11:49:13

标签: java geotools graphics

有没有办法在Java Graphics中创建一个用于符号化点的样式?我有一个返回Java图形的类,但无法确定如何从中创建样式

public Graphic crtaj(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    Double s = new Double((double) ((float) this._x - 10.0F * this._f),
            (double) ((float) this._y - 10.0F * this._f), (double) (20.0F * this._f), (double) (20.0F * this._f));
    crtajPodlogu(g2, s);
    g2.draw(new Double((double) ((float) this._x - 5.0F * this._f), (double) ((float) this._y - 5.0F * this._f),
            (double) (10.0F * this._f), (double) (10.0F * this._f)));
    g2.draw(new Double((double) this._x - 0.5D, (double) this._y - 0.5D, 1.0D, 1.0D));
    g2.draw(new Float((float) this._x, (float) this._y - 10.0F * this._f, (float) this._x,
            (float) this._y - 20.0F * this._f));
    g2.draw(new Float((float) this._x - 10.0F * this._f, (float) this._y - 15.0F * this._f,
            (float) this._x + 10.0F * this._f, (float) this._y - 15.0F * this._f));
    g2.draw(new Float((float) this._x - 10.0F * this._f, (float) this._y - 20.0F * this._f,
            (float) this._x + 10.0F * this._f, (float) this._y - 20.0F * this._f));
    g2.draw(new Float((float) this._x + 10.0F * this._f, (float) this._y - 20.0F * this._f, (float) this._x,
            (float) this._y - 40.0F * this._f));
    g2.draw(new Float((float) this._x, (float) this._y - 40.0F * this._f, (float) this._x - 10.0F * this._f,
            (float) this._y - 20.0F * this._f));
    g2.draw(new java.awt.geom.Rectangle2D.Double((double) ((float) this._x - 2.0F * this._f),
            (double) ((float) this._y - 30.0F * this._f), (double) (4.0F * this._f), (double) (8.0F * this._f)));
    return (Graphic) g;

}

另一个和第三个班级

Class e = Class.forName("topkljuc." + this.nazivKlase);
try {
    TackaZnak e2 = (TackaZnak) e.newInstance();
    e2._x = (long) (this.getWidth() / 2);
    e2._y = (long) (this.getHeight() / 2);
    this.postaviBoju(g);
    e2.crtaj(g);
    this.vratiStaruBoju(g);
} catch (Exception arg20) {
    g.drawString(arg20 + " " + e.getName(), 20, 20);
}


public Graphic crtaj(Graphics g) {
    g.setColor(this.getForeground());
    return (Graphic) g;
}

我在我的课程中只发布了部分代码

0 个答案:

没有答案