1 27 28 package org.nightlabs.editor2d.util; 29 30 import org.eclipse.draw2d.ColorConstants; 31 import org.eclipse.swt.graphics.Color; 32 import org.nightlabs.editor2d.DrawComponentContainer; 33 import org.nightlabs.editor2d.ImageDrawComponent; 34 import org.nightlabs.editor2d.ShapeDrawComponent; 35 import org.nightlabs.editor2d.figures.FeedbackShapeFigure; 36 import org.nightlabs.editor2d.figures.ShapeFigure; 37 import org.nightlabs.editor2d.j2d.GeneralShape; 38 import org.nightlabs.editor2d.j2d.GeneralShapeFactory; 39 40 41 public class FeedbackUtil 42 { 43 45 public FeedbackUtil() 46 { 47 super(); 48 } 55 56 public static Color GHOST_FILL_COLOR = new Color(null, 31, 31, 31); 57 public static final Color DEFAULT_BGCOLOR = ColorConstants.darkGray; 58 public static final Color DEFAULT_FGCOLOR = ColorConstants.white; 59 60 protected static Color bgColor = DEFAULT_BGCOLOR; 61 public static Color getBackgroundColor() { 62 return bgColor; 63 } 64 65 protected static Color fgColor = DEFAULT_FGCOLOR; 66 public static Color getForegroundColor() { 67 return fgColor; 68 } 69 70 public static ShapeFigure getCustomFeedbackFigure(Object modelPart) 71 { 73 GeneralShape gs = null; 74 if (modelPart instanceof ShapeDrawComponent) { 75 ShapeDrawComponent sdc = (ShapeDrawComponent) modelPart; 76 gs = (GeneralShape)sdc.getGeneralShape().clone(); 77 } 78 else if (modelPart instanceof ImageDrawComponent) { 79 ImageDrawComponent idc = (ImageDrawComponent) modelPart; 80 gs = (GeneralShape) idc.getImageShape().clone(); 81 } 82 else if (modelPart instanceof DrawComponentContainer) 83 { 84 DrawComponentContainer container = (DrawComponentContainer) modelPart; 85 ShapeFigure containerFigure = new FeedbackShapeFigure(); 86 GeneralShape containerShape = GeneralShapeFactory.createRectangle(1,1,1,1); 87 containerFigure.setGeneralShape(containerShape); 88 containerFigure.setXOR(true); 89 containerFigure.setFill(true); 90 containerFigure.setBackgroundColor(bgColor); 91 containerFigure.setForegroundColor(fgColor); 92 return containerFigure; 98 } 99 else { 100 gs = GeneralShapeFactory.createRectangle(0, 0, 10, 10); 101 } 102 ShapeFigure shapeFigure = new FeedbackShapeFigure(); 103 shapeFigure.setGeneralShape(gs); 104 shapeFigure.setXOR(true); 105 shapeFigure.setFill(true); 106 shapeFigure.setBackgroundColor(bgColor); 107 shapeFigure.setForegroundColor(fgColor); 108 return shapeFigure; 109 } 110 111 151 185 193 194 } 195 | Popular Tags |