sourcforge > sotacs
 

Example 1 : Circle

A very simple example

Screenshot

Blue PNG-circle

Note
This is static documentation. You can see this example live

Circle.html

			
<img jwcid="@sotacs:DynamicImage" parameters="literal:This is a blue PNG-circle" 
	height="200" width="200"  painter="painter:paintWelcomeCircle" />
	    

Circle.java

			
public abstract class Circle extends BasePage{
	public void paintWelcomeCircle(Graphics2D g2d, IPainterContext context){
		// Enable antialiasing for shapes
		g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_ON);
					   
		//draw a blue circle
		g2d.setColor(new Color(150,150,255));
		g2d.fillOval(0,0,context.getWidth(), context.getHeight());
					   
		//retrieve the message
		Object[] oo = context.getParameters();
		String msg = (String)(oo[0]);
					   
		//draw the message
		g2d.setColor(Color.BLACK);
		g2d.setFont(g2d.getFont().deriveFont(Font.BOLD));
		g2d.drawString(msg , (int)(context.getWidth() * 0.15), 
			(int)(context.getHeight() * 0.4));
	}
  }