+++ /dev/null
-package jp.sourceforge.stigmata.ui.swing.mds;
-
-/*
- * $Id$
- */
-
-import java.awt.Graphics2D;
-
-/**
- * @author Haruaki TAMADA
- * @version $Revision$ $Date$
- */
-public interface MarkDrawer{
- public void draw(Graphics2D g, int w, int h);
-
- public void drawOver(Graphics2D g, int w, int h);
-}
+++ /dev/null
-package jp.sourceforge.stigmata.ui.swing.mds.mark;
-
-/*
- * $Id$
- */
-
-import java.awt.Graphics2D;
-import java.awt.Shape;
-import java.awt.Stroke;
-
-import jp.sourceforge.stigmata.ui.swing.mds.MarkDrawer;
-
-/**
- *
- * @author Haruaki TAMADA
- * @version $Revision$ $Date$
- */
-abstract class AbstractMarkDrawer implements MarkDrawer{
- private boolean fill;
-
- public AbstractMarkDrawer(){
- this(false);
- }
-
- public AbstractMarkDrawer(boolean fill){
- setFilled(fill);
- }
-
- public boolean isFilled(){
- return fill;
- }
-
- public void setFilled(boolean fill){
- this.fill = fill;
- }
-
- public abstract Shape getPlainShape(int w, int h);
-
- public abstract Shape getOveredShape(int w, int h);
-
- public Stroke getPlainStroke(){
- return null;
- }
-
- public Stroke getOverStroke(){
- return null;
- }
-
- public void draw(Graphics2D g, int w, int h){
- Stroke s = getPlainStroke();
- if(s != null){
- g.setStroke(s);
- }
- drawImpl(g, getPlainShape(w, h));
- }
-
- public void drawOver(Graphics2D g, int w, int h){
- Stroke s = getOverStroke();
- if(s != null){
- g.setStroke(s);
- }
- drawImpl(g, getOveredShape(w, h));
- }
-
- private void drawImpl(Graphics2D g, Shape s){
- if(isFilled()){
- g.fill(s);
- }
- else{
- g.draw(s);
- }
- }
-}
+++ /dev/null
-package jp.sourceforge.stigmata.ui.swing.mds.mark;
-
-/*
- * $Id$
- */
-
-import java.awt.Shape;
-import java.awt.geom.Ellipse2D;
-
-/**
- *
- * @author Haruaki TAMADA
- * @version $Revision$ $Date$
- */
-class CircleDrawer extends AbstractMarkDrawer{
-
- public CircleDrawer(){
- super();
- }
-
- public CircleDrawer(boolean fill){
- super(fill);
- }
-
- @Override
- public Shape getPlainShape(int w, int h){
- double ww = (double)w / 2d;
- double hh = (double)h / 2d;
-
- return new Ellipse2D.Double(ww - 2d, hh - 2d, 4d, 4d);
- }
-
- @Override
- public Shape getOveredShape(int w, int h){
- return new Ellipse2D.Double(0, 0, w - 1d, h - 1d);
- }
-}
+++ /dev/null
-package jp.sourceforge.stigmata.ui.swing.mds.mark;
-
-/*
- * $Id$
- */
-
-import java.awt.Shape;
-import java.awt.geom.GeneralPath;
-
-/**
- *
- * @author Haruaki TAMADA
- * @version $Revision$ $Date$
- */
-class CrossDrawer extends LineMarkDrawer{
- public CrossDrawer(){
- }
-
- @Override
- public Shape getPlainShape(int w, int h){
- float ww = w / 2f;
- float hh = h / 2f;
-
- GeneralPath path = new GeneralPath();
- path.moveTo(0, hh);
- path.lineTo(w, hh);
- path.moveTo(ww, 0);
- path.lineTo(ww, h);
-
- return path;
- }
-
- @Override
- public Shape getOveredShape(int w, int h){
- return getPlainShape(w, h);
- }
-}
+++ /dev/null
-package jp.sourceforge.stigmata.ui.swing.mds.mark;
-
-/*
- * $Id$
- */
-
-import java.awt.Shape;
-import java.awt.geom.GeneralPath;
-
-/**
- *
- * @author Haruaki TAMADA
- * @version $Revision$ $Date$
- */
-class DownerTriangleDrawer extends AbstractMarkDrawer{
- public DownerTriangleDrawer(){
- super();
- }
-
- public DownerTriangleDrawer(boolean fill){
- super(fill);
- }
-
- @Override
- public Shape getPlainShape(int w, int h){
- float ww = (float)w / 2f;
- float hh = (float)h / 2f;
-
- GeneralPath path = new GeneralPath();
- path.moveTo(ww - 2f, hh - 2f);
- path.lineTo(ww + 2f, hh - 2f);
- path.lineTo(ww, hh - 2f + (float)(2 * Math.sqrt(3)));
- path.lineTo(ww - 2f, hh - 2f);
-
- return path;
- }
-
- @Override
- public Shape getOveredShape(int w, int h){
- GeneralPath path = new GeneralPath();
- path.moveTo(0, 0);
- path.lineTo(w, 0);
- path.lineTo(w / 2f, h);
- path.lineTo(0, 0);
-
- return path;
- }
-
-}
+++ /dev/null
-package jp.sourceforge.stigmata.ui.swing.mds.mark;
-
-/*
- * $Id$
- */
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.swing.Icon;
-
-import jp.sourceforge.stigmata.ui.swing.mds.GeometoryType;
-import jp.sourceforge.stigmata.ui.swing.mds.MarkDrawer;
-import jp.sourceforge.stigmata.ui.swing.mds.MarkIcon;
-
-/**
- *
- * @author Haruaki TAMADA
- * @version $Revision$ $Date$
- */
-public class DrawerFactory{
- private static final DrawerFactory instance = new DrawerFactory();
-
- private Map<GeometoryType, MarkDrawer> drawers = new HashMap<GeometoryType, MarkDrawer>();
-
- private DrawerFactory(){
- drawers.put(GeometoryType.CROSS, new CrossDrawer());
- drawers.put(GeometoryType.XMARK, new XMarkDrawer());
- drawers.put(GeometoryType.STAR, new StarDrawer());
- drawers.put(GeometoryType.CIRCLE, new CircleDrawer());
- drawers.put(GeometoryType.FILLED_CIRCLE, new CircleDrawer(true));
- drawers.put(GeometoryType.RHOMBUS, new RhombusDrawer());
- drawers.put(GeometoryType.FILLED_RHOMBUS, new RhombusDrawer(true));
- drawers.put(GeometoryType.RECTANGLE, new RectangleDrawer());
- drawers.put(GeometoryType.FILLED_RECTANGLE, new RectangleDrawer(true));
- drawers.put(GeometoryType.UPPER_TRIANGLE, new UpperTriangleDrawer());
- drawers.put(GeometoryType.FILLED_UPPER_TRIANGLE, new UpperTriangleDrawer(true));
- drawers.put(GeometoryType.DOWNER_TRIANGLE, new DownerTriangleDrawer());
- drawers.put(GeometoryType.FILLED_DOWNER_TRIANGLE, new DownerTriangleDrawer(true));
- }
-
- public static DrawerFactory getInstance(){
- return instance;
- }
-
- public MarkDrawer create(GeometoryType type){
- return drawers.get(type);
- }
-
- public Icon createIcon(GeometoryType type){
- return new MarkIcon(create(type));
- }
-}
+++ /dev/null
-package jp.sourceforge.stigmata.ui.swing.mds.mark;
-
-/*
- * $Id$
- */
-
-import java.awt.BasicStroke;
-import java.awt.Stroke;
-
-/**
- *
- * @author Haruaki TAMADA
- * @version $Revision$ $Date$
- */
-abstract class LineMarkDrawer extends AbstractMarkDrawer{
- public LineMarkDrawer(){
- }
-
- @Override
- public boolean isFilled(){
- return false;
- }
-
- @Override
- public void setFilled(boolean fill){
- // nothing to to.
- }
-
- @Override
- public Stroke getOverStroke(){
- return new BasicStroke(3f);
- }
-
-}
+++ /dev/null
-package jp.sourceforge.stigmata.ui.swing.mds.mark;
-
-/*
- * $Id$
- */
-
-import java.awt.Shape;
-import java.awt.geom.Rectangle2D;
-
-/**
- *
- * @author Haruaki TAMADA
- * @version $Revision$ $Date$
- */
-class RectangleDrawer extends AbstractMarkDrawer{
-
- public RectangleDrawer(){
- super();
- }
-
- public RectangleDrawer(boolean fill){
- super(fill);
- }
-
- @Override
- public Shape getPlainShape(int w, int h){
- double ww = (double)w / 2d;
- double hh = (double)h / 2d;
-
- return new Rectangle2D.Double(ww - 2d, hh - 2d, 4d, 4d);
- }
-
- @Override
- public Shape getOveredShape(int w, int h){
- return new Rectangle2D.Double(0, 0, w - 1, h - 1);
- }
-}
+++ /dev/null
-package jp.sourceforge.stigmata.ui.swing.mds.mark;
-
-/*
- * $Id$
- */
-
-import java.awt.Shape;
-import java.awt.geom.GeneralPath;
-
-/**
- *
- * @author Haruaki TAMADA
- * @version $Revision$ $Date$
- */
-class RhombusDrawer extends AbstractMarkDrawer{
-
- public RhombusDrawer(){
- super();
- }
-
- public RhombusDrawer(boolean fill){
- super(fill);
- }
-
- @Override
- public Shape getPlainShape(int w, int h){
- float ww = (float)w / 2f;
- float hh = (float)h / 2f;
-
- GeneralPath path = new GeneralPath();
- path.moveTo(ww, hh - 2f);
- path.lineTo(ww + 2f, hh);
- path.lineTo(ww, hh + 2f);
- path.lineTo(ww - 2f, hh);
- path.lineTo(ww, hh - 2f);
-
- return path;
- }
-
- @Override
- public Shape getOveredShape(int w, int h){
- float ww = (float)w / 2f;
- float hh = (float)h / 2f;
-
- GeneralPath path = new GeneralPath();
- path.moveTo(ww, 0);
- path.lineTo(0, hh);
- path.lineTo(ww, h);
- path.lineTo(w, hh);
- path.lineTo(ww, 0);
-
- return path;
- }
-
-}
+++ /dev/null
-package jp.sourceforge.stigmata.ui.swing.mds.mark;
-
-/*
- * $Id$
- */
-
-import java.awt.Shape;
-import java.awt.geom.GeneralPath;
-
-/**
- *
- * @author Haruaki TAMADA
- * @version $Revision$ $Date$
- */
-class StarDrawer extends LineMarkDrawer{
- public StarDrawer(){
- }
-
- @Override
- public Shape getPlainShape(int w, int h){
- float ww = w / 2f;
- float hh = h / 2f;
-
- GeneralPath path = new GeneralPath();
- path.moveTo(0, hh); path.lineTo(w, hh);
- path.moveTo(ww, 0); path.lineTo(ww, h);
- path.moveTo(0, 0); path.lineTo(w, h);
- path.moveTo(w, 0); path.lineTo(0, h);
-
- return path;
- }
-
- @Override
- public Shape getOveredShape(int w, int h){
- return getPlainShape(w, h);
- }
-}
+++ /dev/null
-package jp.sourceforge.stigmata.ui.swing.mds.mark;
-
-/*
- * $Id$
- */
-
-import java.awt.Shape;
-import java.awt.geom.GeneralPath;
-
-/**
- *
- * @author Haruaki TAMADA
- * @version $Revision$ $Date$
- */
-class UpperTriangleDrawer extends AbstractMarkDrawer{
-
- public UpperTriangleDrawer(){
- super();
- }
-
- public UpperTriangleDrawer(boolean fill){
- super(fill);
- }
-
- @Override
- public Shape getPlainShape(int w, int h){
- float ww = (float)w / 2f;
- float hh = (float)h / 2f;
-
- GeneralPath path = new GeneralPath();
- path.moveTo(ww - 2f, hh + 2f);
- path.lineTo(ww + 2f, hh + 2f);
- path.lineTo(ww, hh + 2f - (float)(2 * Math.sqrt(3)));
- path.lineTo(ww - 2f, hh + 2f);
-
- return path;
- }
-
- @Override
- public Shape getOveredShape(int w, int h){
- GeneralPath path = new GeneralPath();
- path.moveTo(0, h - 1f);
- path.lineTo(w, h - 1f);
- path.lineTo(w / 2f, 0);
- path.lineTo(0, h - 1f);
-
- return path;
- }
-
-}
+++ /dev/null
-package jp.sourceforge.stigmata.ui.swing.mds.mark;
-
-/*
- * $Id$
- */
-
-import java.awt.Shape;
-import java.awt.geom.GeneralPath;
-
-/**
- *
- * @author Haruaki TAMADA
- * @version $Revision$ $Date$
- */
-class XMarkDrawer extends LineMarkDrawer{
- public XMarkDrawer(){
- }
-
- @Override
- public Shape getPlainShape(int w, int h){
- GeneralPath path = new GeneralPath();
- path.moveTo(0, 0);
- path.lineTo(w, h);
- path.moveTo(w, 0);
- path.lineTo(0, h);
-
- return path;
- }
-
- @Override
- public Shape getOveredShape(int w, int h){
- return getPlainShape(w, h);
- }
-}