Java 类org.newdawn.slick.geom.Shape 实例源码

项目:trashjam2017    文件:RadialGradientFill.java   
/**
 * Create a new fill for a radial gradient
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape in the SVG
 * @param gradient The gradient to apply across the shape
 */
public RadialGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    radius = gradient.getR();
    float x = gradient.getX1();
    float y = gradient.getY1();

    float[] c = new float[] {x,y};
    gradient.getTransform().transform(c, 0, c, 0, 1);
    trans.transform(c, 0, c, 0, 1);
    float[] rt = new float[] {x,y-radius};
    gradient.getTransform().transform(rt, 0, rt, 0, 1);
    trans.transform(rt, 0, rt, 0, 1);

    centre = new Vector2f(c[0],c[1]);
    Vector2f dis = new Vector2f(rt[0],rt[1]);
    radius = dis.distance(centre);
}
项目:trashjam2017    文件:UseProcessor.java   
/**
 * @see org.newdawn.slick.svg.inkscape.ElementProcessor#process(org.newdawn.slick.svg.Loader, org.w3c.dom.Element, org.newdawn.slick.svg.Diagram, org.newdawn.slick.geom.Transform)
 */
public void process(Loader loader, Element element, Diagram diagram,
        Transform transform) throws ParsingException {

    String ref = element.getAttributeNS("http://www.w3.org/1999/xlink", "href");
    String href = Util.getAsReference(ref);

    Figure referenced = diagram.getFigureByID(href);
    if (referenced == null) {
        throw new ParsingException(element, "Unable to locate referenced element: "+href);
    }

    Transform local = Util.getTransform(element);
    Transform trans = local.concatenate(referenced.getTransform());

    NonGeometricData data = Util.getNonGeometricData(element);
    Shape shape = referenced.getShape().transform(trans);
    data.addAttribute(NonGeometricData.FILL, referenced.getData().getAttribute(NonGeometricData.FILL));
    data.addAttribute(NonGeometricData.STROKE, referenced.getData().getAttribute(NonGeometricData.STROKE));
    data.addAttribute(NonGeometricData.OPACITY, referenced.getData().getAttribute(NonGeometricData.OPACITY));
    data.addAttribute(NonGeometricData.STROKE_WIDTH, referenced.getData().getAttribute(NonGeometricData.STROKE_WIDTH));

    Figure figure = new Figure(referenced.getType(), shape, data, trans);
    diagram.addFigure(figure);
}
项目:trashjam2017    文件:LinearGradientFill.java   
/**
 * Create a new fill for gradients
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape
 * @param gradient The gradient to apply
 */
public LinearGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    float x = gradient.getX1();
    float y = gradient.getY1();
    float mx = gradient.getX2();
    float my = gradient.getY2();

    float h = my - y;
    float w = mx - x;

    float[] s = new float[] {x,y+(h/2)};
    gradient.getTransform().transform(s, 0, s, 0, 1);
    trans.transform(s, 0, s, 0, 1);
    float[] e = new float[] {x+w,y+(h/2)};
    gradient.getTransform().transform(e, 0, e, 0, 1);
    trans.transform(e, 0, e, 0, 1);

    start = new Vector2f(s[0],s[1]);
    end = new Vector2f(e[0],e[1]);

    line = new Line(start, end);
}
项目:trashjam2017    文件:ShapeTest.java   
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
    g.setColor(Color.green);

    for(int i=0;i<shapes.size();i++) {
        g.fill((Shape)shapes.get(i));
    }
    g.fill(randomShape);
    g.setColor(Color.black);
    g.setAntiAlias(true);
    g.draw(randomShape);
    g.setAntiAlias(false);

    g.setColor(Color.white);
    g.drawString("keys", 10, 300);
    g.drawString("wasd - move rectangle", 10, 315);
    g.drawString("WASD - resize rectangle", 10, 330);
    g.drawString("tgfh - move rounded rectangle", 10, 345);
    g.drawString("TGFH - resize rounded rectangle", 10, 360);
    g.drawString("ry - resize corner radius on rounded rectangle", 10, 375);
    g.drawString("ikjl - move ellipse", 10, 390);
    g.drawString("IKJL - resize ellipse", 10, 405);
    g.drawString("Arrows - move circle", 10, 420);
    g.drawString("Page Up/Page Down - resize circle", 10, 435);
    g.drawString("numpad 8546 - move polygon", 10, 450);
}
项目:trashjam2017    文件:GeomUtilTileTest.java   
/**
 * Combine a set of shapes together
 * 
 * @param shapes
 *            The shapes to be combined
 * @return The list of combined shapes
 */
private ArrayList combine(ArrayList shapes) {
    ArrayList last = shapes;
    ArrayList current = shapes;
    boolean first = true;

    while ((current.size() != last.size()) || (first)) {
        first = false;
        last = current;
        current = combineImpl(current);
    }

    ArrayList pruned = new ArrayList();
    for (int i = 0; i < current.size(); i++) {
        pruned.add(((Shape) current.get(i)).prune());
    }
    return pruned;
}
项目:trashjam2017    文件:MouseOverArea.java   
/**
 * Create a new mouse over area
 * 
 * @param container
 *            The container displaying the mouse over area
 * @param image
 *            The normalImage to display
 * @param shape
 *            The shape defining the area of the mouse sensitive zone
 */
public MouseOverArea(GUIContext container, Image image, Shape shape) {
    super(container);

    area = shape;
    normalImage = image;
    currentImage = image;
    mouseOverImage = image;
    mouseDownImage = image;

    currentColor = normalColor;

    state = NORMAL;
    Input input = container.getInput();
    over = area.contains(input.getMouseX(), input.getMouseY());
    mouseDown = input.isMouseButtonDown(0);
    updateImage();
}
项目:Progetto-C    文件:RadialGradientFill.java   
/**
 * Create a new fill for a radial gradient
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape in the SVG
 * @param gradient The gradient to apply across the shape
 */
public RadialGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    radius = gradient.getR();
    float x = gradient.getX1();
    float y = gradient.getY1();

    float[] c = new float[] {x,y};
    gradient.getTransform().transform(c, 0, c, 0, 1);
    trans.transform(c, 0, c, 0, 1);
    float[] rt = new float[] {x,y-radius};
    gradient.getTransform().transform(rt, 0, rt, 0, 1);
    trans.transform(rt, 0, rt, 0, 1);

    centre = new Vector2f(c[0],c[1]);
    Vector2f dis = new Vector2f(rt[0],rt[1]);
    radius = dis.distance(centre);
}
项目:Progetto-C    文件:UseProcessor.java   
/**
 * @see org.newdawn.slick.svg.inkscape.ElementProcessor#process(org.newdawn.slick.svg.Loader, org.w3c.dom.Element, org.newdawn.slick.svg.Diagram, org.newdawn.slick.geom.Transform)
 */
public void process(Loader loader, Element element, Diagram diagram,
        Transform transform) throws ParsingException {

    String ref = element.getAttributeNS("http://www.w3.org/1999/xlink", "href");
    String href = Util.getAsReference(ref);

    Figure referenced = diagram.getFigureByID(href);
    if (referenced == null) {
        throw new ParsingException(element, "Unable to locate referenced element: "+href);
    }

    Transform local = Util.getTransform(element);
    Transform trans = local.concatenate(referenced.getTransform());

    NonGeometricData data = Util.getNonGeometricData(element);
    Shape shape = referenced.getShape().transform(trans);
    data.addAttribute(NonGeometricData.FILL, referenced.getData().getAttribute(NonGeometricData.FILL));
    data.addAttribute(NonGeometricData.STROKE, referenced.getData().getAttribute(NonGeometricData.STROKE));
    data.addAttribute(NonGeometricData.OPACITY, referenced.getData().getAttribute(NonGeometricData.OPACITY));
    data.addAttribute(NonGeometricData.STROKE_WIDTH, referenced.getData().getAttribute(NonGeometricData.STROKE_WIDTH));

    Figure figure = new Figure(referenced.getType(), shape, data, trans);
    diagram.addFigure(figure);
}
项目:Progetto-C    文件:LinearGradientFill.java   
/**
 * Create a new fill for gradients
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape
 * @param gradient The gradient to apply
 */
public LinearGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    float x = gradient.getX1();
    float y = gradient.getY1();
    float mx = gradient.getX2();
    float my = gradient.getY2();

    float h = my - y;
    float w = mx - x;

    float[] s = new float[] {x,y+(h/2)};
    gradient.getTransform().transform(s, 0, s, 0, 1);
    trans.transform(s, 0, s, 0, 1);
    float[] e = new float[] {x+w,y+(h/2)};
    gradient.getTransform().transform(e, 0, e, 0, 1);
    trans.transform(e, 0, e, 0, 1);

    start = new Vector2f(s[0],s[1]);
    end = new Vector2f(e[0],e[1]);

    line = new Line(start, end);
}
项目:Progetto-C    文件:ShapeTest.java   
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
    g.setColor(Color.green);

    for(int i=0;i<shapes.size();i++) {
        g.fill((Shape)shapes.get(i));
    }
    g.fill(randomShape);
    g.setColor(Color.black);
    g.setAntiAlias(true);
    g.draw(randomShape);
    g.setAntiAlias(false);

    g.setColor(Color.white);
    g.drawString("keys", 10, 300);
    g.drawString("wasd - move rectangle", 10, 315);
    g.drawString("WASD - resize rectangle", 10, 330);
    g.drawString("tgfh - move rounded rectangle", 10, 345);
    g.drawString("TGFH - resize rounded rectangle", 10, 360);
    g.drawString("ry - resize corner radius on rounded rectangle", 10, 375);
    g.drawString("ikjl - move ellipse", 10, 390);
    g.drawString("IKJL - resize ellipse", 10, 405);
    g.drawString("Arrows - move circle", 10, 420);
    g.drawString("Page Up/Page Down - resize circle", 10, 435);
    g.drawString("numpad 8546 - move polygon", 10, 450);
}
项目:Progetto-C    文件:GeomUtilTileTest.java   
/**
 * Combine a set of shapes together
 * 
 * @param shapes
 *            The shapes to be combined
 * @return The list of combined shapes
 */
private ArrayList combine(ArrayList shapes) {
    ArrayList last = shapes;
    ArrayList current = shapes;
    boolean first = true;

    while ((current.size() != last.size()) || (first)) {
        first = false;
        last = current;
        current = combineImpl(current);
    }

    ArrayList pruned = new ArrayList();
    for (int i = 0; i < current.size(); i++) {
        pruned.add(((Shape) current.get(i)).prune());
    }
    return pruned;
}
项目:Progetto-C    文件:MouseOverArea.java   
/**
 * Create a new mouse over area
 * 
 * @param container
 *            The container displaying the mouse over area
 * @param image
 *            The normalImage to display
 * @param shape
 *            The shape defining the area of the mouse sensitive zone
 */
public MouseOverArea(GUIContext container, Image image, Shape shape) {
    super(container);

    area = shape;
    normalImage = image;
    currentImage = image;
    mouseOverImage = image;
    mouseDownImage = image;

    currentColor = normalColor;

    state = NORMAL;
    Input input = container.getInput();
    over = area.contains(input.getMouseX(), input.getMouseY());
    mouseDown = input.isMouseButtonDown(0);
    updateImage();
}
项目:BaseClient    文件:RadialGradientFill.java   
/**
 * Create a new fill for a radial gradient
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape in the SVG
 * @param gradient The gradient to apply across the shape
 */
public RadialGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    radius = gradient.getR();
    float x = gradient.getX1();
    float y = gradient.getY1();

    float[] c = new float[] {x,y};
    gradient.getTransform().transform(c, 0, c, 0, 1);
    trans.transform(c, 0, c, 0, 1);
    float[] rt = new float[] {x,y-radius};
    gradient.getTransform().transform(rt, 0, rt, 0, 1);
    trans.transform(rt, 0, rt, 0, 1);

    centre = new Vector2f(c[0],c[1]);
    Vector2f dis = new Vector2f(rt[0],rt[1]);
    radius = dis.distance(centre);
}
项目:BaseClient    文件:UseProcessor.java   
/**
 * @see org.newdawn.slick.svg.inkscape.ElementProcessor#process(org.newdawn.slick.svg.Loader, org.w3c.dom.Element, org.newdawn.slick.svg.Diagram, org.newdawn.slick.geom.Transform)
 */
public void process(Loader loader, Element element, Diagram diagram,
        Transform transform) throws ParsingException {

    String ref = element.getAttributeNS("http://www.w3.org/1999/xlink", "href");
    String href = Util.getAsReference(ref);

    Figure referenced = diagram.getFigureByID(href);
    if (referenced == null) {
        throw new ParsingException(element, "Unable to locate referenced element: "+href);
    }

    Transform local = Util.getTransform(element);
    Transform trans = local.concatenate(referenced.getTransform());

    NonGeometricData data = Util.getNonGeometricData(element);
    Shape shape = referenced.getShape().transform(trans);
    data.addAttribute(NonGeometricData.FILL, referenced.getData().getAttribute(NonGeometricData.FILL));
    data.addAttribute(NonGeometricData.STROKE, referenced.getData().getAttribute(NonGeometricData.STROKE));
    data.addAttribute(NonGeometricData.OPACITY, referenced.getData().getAttribute(NonGeometricData.OPACITY));
    data.addAttribute(NonGeometricData.STROKE_WIDTH, referenced.getData().getAttribute(NonGeometricData.STROKE_WIDTH));

    Figure figure = new Figure(referenced.getType(), shape, data, trans);
    diagram.addFigure(figure);
}
项目:BaseClient    文件:LinearGradientFill.java   
/**
 * Create a new fill for gradients
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape
 * @param gradient The gradient to apply
 */
public LinearGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    float x = gradient.getX1();
    float y = gradient.getY1();
    float mx = gradient.getX2();
    float my = gradient.getY2();

    float h = my - y;
    float w = mx - x;

    float[] s = new float[] {x,y+(h/2)};
    gradient.getTransform().transform(s, 0, s, 0, 1);
    trans.transform(s, 0, s, 0, 1);
    float[] e = new float[] {x+w,y+(h/2)};
    gradient.getTransform().transform(e, 0, e, 0, 1);
    trans.transform(e, 0, e, 0, 1);

    start = new Vector2f(s[0],s[1]);
    end = new Vector2f(e[0],e[1]);

    line = new Line(start, end);
}
项目:BaseClient    文件:ShapeTest.java   
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
    g.setColor(Color.green);

    for(int i=0;i<shapes.size();i++) {
        g.fill((Shape)shapes.get(i));
    }
    g.fill(randomShape);
    g.setColor(Color.black);
    g.setAntiAlias(true);
    g.draw(randomShape);
    g.setAntiAlias(false);

    g.setColor(Color.white);
    g.drawString("keys", 10, 300);
    g.drawString("wasd - move rectangle", 10, 315);
    g.drawString("WASD - resize rectangle", 10, 330);
    g.drawString("tgfh - move rounded rectangle", 10, 345);
    g.drawString("TGFH - resize rounded rectangle", 10, 360);
    g.drawString("ry - resize corner radius on rounded rectangle", 10, 375);
    g.drawString("ikjl - move ellipse", 10, 390);
    g.drawString("IKJL - resize ellipse", 10, 405);
    g.drawString("Arrows - move circle", 10, 420);
    g.drawString("Page Up/Page Down - resize circle", 10, 435);
    g.drawString("numpad 8546 - move polygon", 10, 450);
}
项目:BaseClient    文件:GeomUtilTileTest.java   
/**
 * Combine a set of shapes together
 * 
 * @param shapes
 *            The shapes to be combined
 * @return The list of combined shapes
 */
private ArrayList combine(ArrayList shapes) {
    ArrayList last = shapes;
    ArrayList current = shapes;
    boolean first = true;

    while ((current.size() != last.size()) || (first)) {
        first = false;
        last = current;
        current = combineImpl(current);
    }

    ArrayList pruned = new ArrayList();
    for (int i = 0; i < current.size(); i++) {
        pruned.add(((Shape) current.get(i)).prune());
    }
    return pruned;
}
项目:BaseClient    文件:MouseOverArea.java   
/**
 * Create a new mouse over area
 * 
 * @param container
 *            The container displaying the mouse over area
 * @param image
 *            The normalImage to display
 * @param shape
 *            The shape defining the area of the mouse sensitive zone
 */
public MouseOverArea(GUIContext container, Image image, Shape shape) {
    super(container);

    area = shape;
    normalImage = image;
    currentImage = image;
    mouseOverImage = image;
    mouseDownImage = image;

    currentColor = normalColor;

    state = NORMAL;
    Input input = container.getInput();
    over = area.contains(input.getMouseX(), input.getMouseY());
    mouseDown = input.isMouseButtonDown(0);
    updateImage();
}
项目:code404    文件:MouseOverArea.java   
/**
 * Create a new mouse over area
 * 
 * @param container
 *            The container displaying the mouse over area
 * @param image
 *            The normalImage to display
 * @param shape
 *            The shape defining the area of the mouse sensitive zone
 */
public MouseOverArea(GUIContext container, Image image, Shape shape) {
    super(container);

    area = shape;
    normalImage = image;
    currentImage = image;
    mouseOverImage = image;
    mouseDownImage = image;

    currentColor = normalColor;

    state = NORMAL;
    Input input = container.getInput();
    over = area.contains(input.getMouseX(), input.getMouseY());
    mouseDown = input.isMouseButtonDown(0);
    updateImage();
}
项目:GPVM    文件:RadialGradientFill.java   
/**
 * Create a new fill for a radial gradient
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape in the SVG
 * @param gradient The gradient to apply across the shape
 */
public RadialGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    radius = gradient.getR();
    float x = gradient.getX1();
    float y = gradient.getY1();

    float[] c = new float[] {x,y};
    gradient.getTransform().transform(c, 0, c, 0, 1);
    trans.transform(c, 0, c, 0, 1);
    float[] rt = new float[] {x,y-radius};
    gradient.getTransform().transform(rt, 0, rt, 0, 1);
    trans.transform(rt, 0, rt, 0, 1);

    centre = new Vector2f(c[0],c[1]);
    Vector2f dis = new Vector2f(rt[0],rt[1]);
    radius = dis.distance(centre);
}
项目:GPVM    文件:UseProcessor.java   
/**
 * @see org.newdawn.slick.svg.inkscape.ElementProcessor#process(org.newdawn.slick.svg.Loader, org.w3c.dom.Element, org.newdawn.slick.svg.Diagram, org.newdawn.slick.geom.Transform)
 */
public void process(Loader loader, Element element, Diagram diagram,
        Transform transform) throws ParsingException {

    String ref = element.getAttributeNS("http://www.w3.org/1999/xlink", "href");
    String href = Util.getAsReference(ref);

    Figure referenced = diagram.getFigureByID(href);
    if (referenced == null) {
        throw new ParsingException(element, "Unable to locate referenced element: "+href);
    }

    Transform local = Util.getTransform(element);
    Transform trans = local.concatenate(referenced.getTransform());

    NonGeometricData data = Util.getNonGeometricData(element);
    Shape shape = referenced.getShape().transform(trans);
    data.addAttribute(NonGeometricData.FILL, referenced.getData().getAttribute(NonGeometricData.FILL));
    data.addAttribute(NonGeometricData.STROKE, referenced.getData().getAttribute(NonGeometricData.STROKE));
    data.addAttribute(NonGeometricData.OPACITY, referenced.getData().getAttribute(NonGeometricData.OPACITY));
    data.addAttribute(NonGeometricData.STROKE_WIDTH, referenced.getData().getAttribute(NonGeometricData.STROKE_WIDTH));

    Figure figure = new Figure(referenced.getType(), shape, data, trans);
    diagram.addFigure(figure);
}
项目:GPVM    文件:LinearGradientFill.java   
/**
 * Create a new fill for gradients
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape
 * @param gradient The gradient to apply
 */
public LinearGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    float x = gradient.getX1();
    float y = gradient.getY1();
    float mx = gradient.getX2();
    float my = gradient.getY2();

    float h = my - y;
    float w = mx - x;

    float[] s = new float[] {x,y+(h/2)};
    gradient.getTransform().transform(s, 0, s, 0, 1);
    trans.transform(s, 0, s, 0, 1);
    float[] e = new float[] {x+w,y+(h/2)};
    gradient.getTransform().transform(e, 0, e, 0, 1);
    trans.transform(e, 0, e, 0, 1);

    start = new Vector2f(s[0],s[1]);
    end = new Vector2f(e[0],e[1]);

    line = new Line(start, end);
}
项目:GPVM    文件:MouseOverArea.java   
/**
 * Create a new mouse over area
 * 
 * @param container
 *            The container displaying the mouse over area
 * @param image
 *            The normalImage to display
 * @param shape
 *            The shape defining the area of the mouse sensitive zone
 */
public MouseOverArea(GUIContext container, Image image, Shape shape) {
    super(container);

    area = shape;
    normalImage = image;
    currentImage = image;
    mouseOverImage = image;
    mouseDownImage = image;

    currentColor = normalColor;

    state = NORMAL;
    Input input = container.getInput();
    over = area.contains(input.getMouseX(), input.getMouseY());
    mouseDown = input.isMouseButtonDown(0);
    updateImage();
}
项目:GPVM    文件:UseProcessor.java   
/**
 * @see org.newdawn.slick.svg.inkscape.ElementProcessor#process(org.newdawn.slick.svg.Loader, org.w3c.dom.Element, org.newdawn.slick.svg.Diagram, org.newdawn.slick.geom.Transform)
 */
public void process(Loader loader, Element element, Diagram diagram,
        Transform transform) throws ParsingException {

    String ref = element.getAttributeNS("http://www.w3.org/1999/xlink", "href");
    String href = Util.getAsReference(ref);

    Figure referenced = diagram.getFigureByID(href);
    if (referenced == null) {
        throw new ParsingException(element, "Unable to locate referenced element: "+href);
    }

    Transform local = Util.getTransform(element);
    Transform trans = local.concatenate(referenced.getTransform());

    NonGeometricData data = Util.getNonGeometricData(element);
    Shape shape = referenced.getShape().transform(trans);
    data.addAttribute(NonGeometricData.FILL, referenced.getData().getAttribute(NonGeometricData.FILL));
    data.addAttribute(NonGeometricData.STROKE, referenced.getData().getAttribute(NonGeometricData.STROKE));
    data.addAttribute(NonGeometricData.OPACITY, referenced.getData().getAttribute(NonGeometricData.OPACITY));
    data.addAttribute(NonGeometricData.STROKE_WIDTH, referenced.getData().getAttribute(NonGeometricData.STROKE_WIDTH));

    Figure figure = new Figure(referenced.getType(), shape, data, trans);
    diagram.addFigure(figure);
}
项目:GPVM    文件:LinearGradientFill.java   
/**
 * Create a new fill for gradients
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape
 * @param gradient The gradient to apply
 */
public LinearGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    float x = gradient.getX1();
    float y = gradient.getY1();
    float mx = gradient.getX2();
    float my = gradient.getY2();

    float h = my - y;
    float w = mx - x;

    float[] s = new float[] {x,y+(h/2)};
    gradient.getTransform().transform(s, 0, s, 0, 1);
    trans.transform(s, 0, s, 0, 1);
    float[] e = new float[] {x+w,y+(h/2)};
    gradient.getTransform().transform(e, 0, e, 0, 1);
    trans.transform(e, 0, e, 0, 1);

    start = new Vector2f(s[0],s[1]);
    end = new Vector2f(e[0],e[1]);

    line = new Line(start, end);
}
项目:GPVM    文件:ShapeTest.java   
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
    g.setColor(Color.green);

    for(int i=0;i<shapes.size();i++) {
        g.fill((Shape)shapes.get(i));
    }
    g.fill(randomShape);
    g.setColor(Color.black);
    g.setAntiAlias(true);
    g.draw(randomShape);
    g.setAntiAlias(false);

    g.setColor(Color.white);
    g.drawString("keys", 10, 300);
    g.drawString("wasd - move rectangle", 10, 315);
    g.drawString("WASD - resize rectangle", 10, 330);
    g.drawString("tgfh - move rounded rectangle", 10, 345);
    g.drawString("TGFH - resize rounded rectangle", 10, 360);
    g.drawString("ry - resize corner radius on rounded rectangle", 10, 375);
    g.drawString("ikjl - move ellipse", 10, 390);
    g.drawString("IKJL - resize ellipse", 10, 405);
    g.drawString("Arrows - move circle", 10, 420);
    g.drawString("Page Up/Page Down - resize circle", 10, 435);
    g.drawString("numpad 8546 - move polygon", 10, 450);
}
项目:GPVM    文件:GeomUtilTileTest.java   
/**
 * Combine a set of shapes together
 * 
 * @param shapes
 *            The shapes to be combined
 * @return The list of combined shapes
 */
private ArrayList combine(ArrayList shapes) {
    ArrayList last = shapes;
    ArrayList current = shapes;
    boolean first = true;

    while ((current.size() != last.size()) || (first)) {
        first = false;
        last = current;
        current = combineImpl(current);
    }

    ArrayList pruned = new ArrayList();
    for (int i = 0; i < current.size(); i++) {
        pruned.add(((Shape) current.get(i)).prune());
    }
    return pruned;
}
项目:GPVM    文件:MouseOverArea.java   
/**
 * Create a new mouse over area
 * 
 * @param container
 *            The container displaying the mouse over area
 * @param image
 *            The normalImage to display
 * @param shape
 *            The shape defining the area of the mouse sensitive zone
 */
public MouseOverArea(GUIContext container, Image image, Shape shape) {
    super(container);

    area = shape;
    normalImage = image;
    currentImage = image;
    mouseOverImage = image;
    mouseDownImage = image;

    currentColor = normalColor;

    state = NORMAL;
    Input input = container.getInput();
    over = area.contains(input.getMouseX(), input.getMouseY());
    mouseDown = input.isMouseButtonDown(0);
    updateImage();
}
项目:SpaceStationAlpha    文件:RadialGradientFill.java   
/**
 * Create a new fill for a radial gradient
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape in the SVG
 * @param gradient The gradient to apply across the shape
 */
public RadialGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    radius = gradient.getR();
    float x = gradient.getX1();
    float y = gradient.getY1();

    float[] c = new float[] {x,y};
    gradient.getTransform().transform(c, 0, c, 0, 1);
    trans.transform(c, 0, c, 0, 1);
    float[] rt = new float[] {x,y-radius};
    gradient.getTransform().transform(rt, 0, rt, 0, 1);
    trans.transform(rt, 0, rt, 0, 1);

    centre = new Vector2f(c[0],c[1]);
    Vector2f dis = new Vector2f(rt[0],rt[1]);
    radius = dis.distance(centre);
}
项目:SpaceStationAlpha    文件:UseProcessor.java   
/**
 * @see org.newdawn.slick.svg.inkscape.ElementProcessor#process(org.newdawn.slick.svg.Loader, org.w3c.dom.Element, org.newdawn.slick.svg.Diagram, org.newdawn.slick.geom.Transform)
 */
public void process(Loader loader, Element element, Diagram diagram,
        Transform transform) throws ParsingException {

    String ref = element.getAttributeNS("http://www.w3.org/1999/xlink", "href");
    String href = Util.getAsReference(ref);

    Figure referenced = diagram.getFigureByID(href);
    if (referenced == null) {
        throw new ParsingException(element, "Unable to locate referenced element: "+href);
    }

    Transform local = Util.getTransform(element);
    Transform trans = local.concatenate(referenced.getTransform());

    NonGeometricData data = Util.getNonGeometricData(element);
    Shape shape = referenced.getShape().transform(trans);
    data.addAttribute(NonGeometricData.FILL, referenced.getData().getAttribute(NonGeometricData.FILL));
    data.addAttribute(NonGeometricData.STROKE, referenced.getData().getAttribute(NonGeometricData.STROKE));
    data.addAttribute(NonGeometricData.OPACITY, referenced.getData().getAttribute(NonGeometricData.OPACITY));
    data.addAttribute(NonGeometricData.STROKE_WIDTH, referenced.getData().getAttribute(NonGeometricData.STROKE_WIDTH));

    Figure figure = new Figure(referenced.getType(), shape, data, trans);
    diagram.addFigure(figure);
}
项目:SpaceStationAlpha    文件:LinearGradientFill.java   
/**
 * Create a new fill for gradients
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape
 * @param gradient The gradient to apply
 */
public LinearGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    float x = gradient.getX1();
    float y = gradient.getY1();
    float mx = gradient.getX2();
    float my = gradient.getY2();

    float h = my - y;
    float w = mx - x;

    float[] s = new float[] {x,y+(h/2)};
    gradient.getTransform().transform(s, 0, s, 0, 1);
    trans.transform(s, 0, s, 0, 1);
    float[] e = new float[] {x+w,y+(h/2)};
    gradient.getTransform().transform(e, 0, e, 0, 1);
    trans.transform(e, 0, e, 0, 1);

    start = new Vector2f(s[0],s[1]);
    end = new Vector2f(e[0],e[1]);

    line = new Line(start, end);
}
项目:SpaceStationAlpha    文件:ShapeTest.java   
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
    g.setColor(Color.green);

    for(int i=0;i<shapes.size();i++) {
        g.fill((Shape)shapes.get(i));
    }
    g.fill(randomShape);
    g.setColor(Color.black);
    g.setAntiAlias(true);
    g.draw(randomShape);
    g.setAntiAlias(false);

    g.setColor(Color.white);
    g.drawString("keys", 10, 300);
    g.drawString("wasd - move rectangle", 10, 315);
    g.drawString("WASD - resize rectangle", 10, 330);
    g.drawString("tgfh - move rounded rectangle", 10, 345);
    g.drawString("TGFH - resize rounded rectangle", 10, 360);
    g.drawString("ry - resize corner radius on rounded rectangle", 10, 375);
    g.drawString("ikjl - move ellipse", 10, 390);
    g.drawString("IKJL - resize ellipse", 10, 405);
    g.drawString("Arrows - move circle", 10, 420);
    g.drawString("Page Up/Page Down - resize circle", 10, 435);
    g.drawString("numpad 8546 - move polygon", 10, 450);
}
项目:SpaceStationAlpha    文件:GeomUtilTileTest.java   
/**
 * Combine a set of shapes together
 * 
 * @param shapes
 *            The shapes to be combined
 * @return The list of combined shapes
 */
private ArrayList combine(ArrayList shapes) {
    ArrayList last = shapes;
    ArrayList current = shapes;
    boolean first = true;

    while ((current.size() != last.size()) || (first)) {
        first = false;
        last = current;
        current = combineImpl(current);
    }

    ArrayList pruned = new ArrayList();
    for (int i = 0; i < current.size(); i++) {
        pruned.add(((Shape) current.get(i)).prune());
    }
    return pruned;
}
项目:SpaceStationAlpha    文件:MouseOverArea.java   
/**
 * Create a new mouse over area
 * 
 * @param container
 *            The container displaying the mouse over area
 * @param image
 *            The normalImage to display
 * @param shape
 *            The shape defining the area of the mouse sensitive zone
 */
public MouseOverArea(GUIContext container, Image image, Shape shape) {
    super(container);

    area = shape;
    normalImage = image;
    currentImage = image;
    mouseOverImage = image;
    mouseDownImage = image;

    currentColor = normalColor;

    state = NORMAL;
    Input input = container.getInput();
    over = area.contains(input.getMouseX(), input.getMouseY());
    mouseDown = input.isMouseButtonDown(0);
    updateImage();
}
项目:cretion    文件:RadialGradientFill.java   
/**
 * Create a new fill for a radial gradient
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape in the SVG
 * @param gradient The gradient to apply across the shape
 */
public RadialGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    radius = gradient.getR();
    float x = gradient.getX1();
    float y = gradient.getY1();

    float[] c = new float[] {x,y};
    gradient.getTransform().transform(c, 0, c, 0, 1);
    trans.transform(c, 0, c, 0, 1);
    float[] rt = new float[] {x,y-radius};
    gradient.getTransform().transform(rt, 0, rt, 0, 1);
    trans.transform(rt, 0, rt, 0, 1);

    centre = new Vector2f(c[0],c[1]);
    Vector2f dis = new Vector2f(rt[0],rt[1]);
    radius = dis.distance(centre);
}
项目:cretion    文件:UseProcessor.java   
/**
 * @see org.newdawn.slick.svg.inkscape.ElementProcessor#process(org.newdawn.slick.svg.Loader, org.w3c.dom.Element, org.newdawn.slick.svg.Diagram, org.newdawn.slick.geom.Transform)
 */
public void process(Loader loader, Element element, Diagram diagram,
        Transform transform) throws ParsingException {

    String ref = element.getAttributeNS("http://www.w3.org/1999/xlink", "href");
    String href = Util.getAsReference(ref);

    Figure referenced = diagram.getFigureByID(href);
    if (referenced == null) {
        throw new ParsingException(element, "Unable to locate referenced element: "+href);
    }

    Transform local = Util.getTransform(element);
    Transform trans = local.concatenate(referenced.getTransform());

    NonGeometricData data = Util.getNonGeometricData(element);
    Shape shape = referenced.getShape().transform(trans);
    data.addAttribute(NonGeometricData.FILL, referenced.getData().getAttribute(NonGeometricData.FILL));
    data.addAttribute(NonGeometricData.STROKE, referenced.getData().getAttribute(NonGeometricData.STROKE));
    data.addAttribute(NonGeometricData.OPACITY, referenced.getData().getAttribute(NonGeometricData.OPACITY));
    data.addAttribute(NonGeometricData.STROKE_WIDTH, referenced.getData().getAttribute(NonGeometricData.STROKE_WIDTH));

    Figure figure = new Figure(referenced.getType(), shape, data, trans);
    diagram.addFigure(figure);
}
项目:cretion    文件:LinearGradientFill.java   
/**
 * Create a new fill for gradients
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape
 * @param gradient The gradient to apply
 */
public LinearGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    float x = gradient.getX1();
    float y = gradient.getY1();
    float mx = gradient.getX2();
    float my = gradient.getY2();

    float h = my - y;
    float w = mx - x;

    float[] s = new float[] {x,y+(h/2)};
    gradient.getTransform().transform(s, 0, s, 0, 1);
    trans.transform(s, 0, s, 0, 1);
    float[] e = new float[] {x+w,y+(h/2)};
    gradient.getTransform().transform(e, 0, e, 0, 1);
    trans.transform(e, 0, e, 0, 1);

    start = new Vector2f(s[0],s[1]);
    end = new Vector2f(e[0],e[1]);

    line = new Line(start, end);
}
项目:cretion    文件:ShapeTest.java   
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
    g.setColor(Color.green);

    for(int i=0;i<shapes.size();i++) {
        g.fill((Shape)shapes.get(i));
    }
    g.fill(randomShape);
    g.setColor(Color.black);
    g.setAntiAlias(true);
    g.draw(randomShape);
    g.setAntiAlias(false);

    g.setColor(Color.white);
    g.drawString("keys", 10, 300);
    g.drawString("wasd - move rectangle", 10, 315);
    g.drawString("WASD - resize rectangle", 10, 330);
    g.drawString("tgfh - move rounded rectangle", 10, 345);
    g.drawString("TGFH - resize rounded rectangle", 10, 360);
    g.drawString("ry - resize corner radius on rounded rectangle", 10, 375);
    g.drawString("ikjl - move ellipse", 10, 390);
    g.drawString("IKJL - resize ellipse", 10, 405);
    g.drawString("Arrows - move circle", 10, 420);
    g.drawString("Page Up/Page Down - resize circle", 10, 435);
    g.drawString("numpad 8546 - move polygon", 10, 450);
}
项目:cretion    文件:GeomUtilTileTest.java   
/**
 * Combine a set of shapes together
 * 
 * @param shapes
 *            The shapes to be combined
 * @return The list of combined shapes
 */
private ArrayList combine(ArrayList shapes) {
    ArrayList last = shapes;
    ArrayList current = shapes;
    boolean first = true;

    while ((current.size() != last.size()) || (first)) {
        first = false;
        last = current;
        current = combineImpl(current);
    }

    ArrayList pruned = new ArrayList();
    for (int i = 0; i < current.size(); i++) {
        pruned.add(((Shape) current.get(i)).prune());
    }
    return pruned;
}
项目:cretion    文件:MouseOverArea.java   
/**
 * Create a new mouse over area
 * 
 * @param container
 *            The container displaying the mouse over area
 * @param image
 *            The normalImage to display
 * @param shape
 *            The shape defining the area of the mouse sensitive zone
 */
public MouseOverArea(GUIContext container, Image image, Shape shape) {
    super(container);

    area = shape;
    normalImage = image;
    currentImage = image;
    mouseOverImage = image;
    mouseDownImage = image;

    currentColor = normalColor;

    state = NORMAL;
    Input input = container.getInput();
    over = area.contains(input.getMouseX(), input.getMouseY());
    mouseDown = input.isMouseButtonDown(0);
    updateImage();
}