|
SceneExampleRoundPin
package org.kordamp.jsilhouette.scenegraph;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.sun.scenario.scenegraph.*;
import org.kordamp.jsilhouette.geom.*;
public class SGRoundPinExample {
public static JSGPanel canvas() {
JSGPanel canvas = new JSGPanel();
canvas.setScene(shape(roundPin(),Color.RED));
return canvas;
}
private static SGRoundPin roundPin() {
SGRoundPin pin = new SGRoundPin();
pin.setCx( 40 );
pin.setCy( 40 );
pin.setRadius( 30 );
pin.setHeight( 60 );
pin.setAngle( 0 );
return pin;
}
private static SGGroup shape( SGShape shape, Color color ) {
SGGroup group = new SGGroup();
group.add( configureShapeForFill(shape,color) );
group.add( configureShapeForStroke(shape) );
return group;
}
private static SGShape configureShapeForFill( SGShape shape, Color color ) {
SGShape s = new SGShape();
s.setShape(shape.getShape());
s.setFillPaint(color);
s.setMode(SGShape.Mode.FILL);
s.setAntialiasingHint(RenderingHints.VALUE_ANTIALIAS_ON);
return s;
}
private static SGShape configureShapeForStroke( SGShape shape ) {
SGShape s = new SGShape();
s.setShape(shape.getShape());
s.setDrawStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER));
s.setDrawPaint(Color.black);
s.setMode(SGShape.Mode.STROKE);
s.setAntialiasingHint(RenderingHints.VALUE_ANTIALIAS_ON);
return s;
}
public static JFrame buildUI() {
JFrame frame = new JFrame("SGRoundPin");
frame.getContentPane().add(canvas());
frame.setSize(new Dimension(90,140));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
return frame;
}
public static void main( String[] args ) {
SwingUtilities.invokeLater( new Runnable() {
public void run() {
buildUI().setVisible(true);
}
});
}
}
|
Sign in to add a comment