Skip to content
Snippets Groups Projects
Commit 7b0acd23 authored by Lukas Ladenberger's avatar Lukas Ladenberger
Browse files

removed canister part/figure + corresponding attributes (moved to

industry plugin)
parent 1786d3be
Branches
Tags
No related merge requests found
Showing
with 0 additions and 427 deletions
de.bmotionstudio.gef.editor/icons/icon_canister.gif

1.02 KiB

...@@ -23,11 +23,6 @@ public final class AttributeConstants { ...@@ -23,11 +23,6 @@ public final class AttributeConstants {
public static final String ATTRIBUTE_IMAGE = "de.bmotionstudio.gef.editor.attribute.BAttributeImage"; public static final String ATTRIBUTE_IMAGE = "de.bmotionstudio.gef.editor.attribute.BAttributeImage";
public static final String ATTRIBUTE_TEXT = "de.bmotionstudio.gef.editor.attribute.BAttributeText"; public static final String ATTRIBUTE_TEXT = "de.bmotionstudio.gef.editor.attribute.BAttributeText";
public static final String ATTRIBUTE_TEXT_COLOR = "de.bmotionstudio.gef.editor.attribute.BAttributeTextColor"; public static final String ATTRIBUTE_TEXT_COLOR = "de.bmotionstudio.gef.editor.attribute.BAttributeTextColor";
public static final String ATTRIBUTE_FILL_HEIGHT = "de.bmotionstudio.gef.editor.attribute.BAttributeFillHeight";
public static final String ATTRIBUTE_FILL_COLOR = "de.bmotionstudio.gef.editor.attribute.BAttributeFillColor";
public static final String ATTRIBUTE_SHOWS_MEASURE = "de.bmotionstudio.gef.editor.attribute.BAttributeShowMeasure";
public static final String ATTRIBUTE_MEASURE_MAXPOS = "de.bmotionstudio.gef.editor.attribute.BAttributeMeasureMaxPos";
public static final String ATTRIBUTE_MEASURE_INTERVAL = "de.bmotionstudio.gef.editor.attribute.BAttributeMeasureInterval";
public static final String ATTRIBUTE_ALPHA = "de.bmotionstudio.gef.editor.attribute.BAttributeAlpha"; public static final String ATTRIBUTE_ALPHA = "de.bmotionstudio.gef.editor.attribute.BAttributeAlpha";
public static final String ATTRIBUTE_OUTLINEALPHA = "de.bmotionstudio.gef.editor.attribute.BAttributeOutlineAlpha"; public static final String ATTRIBUTE_OUTLINEALPHA = "de.bmotionstudio.gef.editor.attribute.BAttributeOutlineAlpha";
public static final String ATTRIBUTE_FONT = "de.bmotionstudio.gef.editor.attribute.BAttributeFont"; public static final String ATTRIBUTE_FONT = "de.bmotionstudio.gef.editor.attribute.BAttributeFont";
......
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.bmotionstudio.gef.editor.attribute;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.ui.views.properties.ColorPropertyDescriptor;
import org.eclipse.ui.views.properties.PropertyDescriptor;
public class BAttributeFillColor extends AbstractAttribute {
public BAttributeFillColor(Object value) {
super(value);
}
public PropertyDescriptor preparePropertyDescriptor() {
return new ColorPropertyDescriptor(getID(), getName());
}
@Override
public String getName() {
return "Fill-Color";
}
@Override
public Object unmarshal(String s) {
String colorStr = s.toLowerCase().replace(" ", "");
colorStr = colorStr.replace("rgb", "");
colorStr = colorStr.replace("}", "");
colorStr = colorStr.replace("{", "");
String[] str = String.valueOf(colorStr).split("\\,");
if (str.length == 3) {
int red = Integer.valueOf(str[0]);
int green = Integer.valueOf(str[1]);
int blue = Integer.valueOf(str[2]);
return new RGB(red, green, blue);
} else {
return new RGB(192, 192, 192);
}
}
}
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.bmotionstudio.gef.editor.attribute;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
public class BAttributeFillHeight extends AbstractAttribute {
public BAttributeFillHeight(Object value) {
super(value);
}
public PropertyDescriptor preparePropertyDescriptor() {
return new TextPropertyDescriptor(getID(), getName());
}
@Override
public String getName() {
return "Fill-Height";
}
}
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.bmotionstudio.gef.editor.attribute;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
public class BAttributeMeasureInterval extends AbstractAttribute {
public BAttributeMeasureInterval(Object value) {
super(value);
}
public PropertyDescriptor preparePropertyDescriptor() {
return new TextPropertyDescriptor(getID(), getName());
}
@Override
public String getName() {
return "Measure-Interval";
}
}
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.bmotionstudio.gef.editor.attribute;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
public class BAttributeMeasureMaxPos extends AbstractAttribute {
public BAttributeMeasureMaxPos(Object value) {
super(value);
}
public PropertyDescriptor preparePropertyDescriptor() {
return new TextPropertyDescriptor(getID(), getName());
}
@Override
public String getName() {
return "Measure-Max-Pos";
}
}
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.bmotionstudio.gef.editor.attribute;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.property.CheckboxPropertyDescriptor;
public class BAttributeShowMeasure extends AbstractAttribute {
public BAttributeShowMeasure(Object value) {
super(value);
}
public PropertyDescriptor preparePropertyDescriptor() {
return new CheckboxPropertyDescriptor(getID(), getName());
}
@Override
public String validateValue(Object value, BControl control) {
if ((String.valueOf(value)).trim().equalsIgnoreCase("true")
|| (String.valueOf(value)).trim().equalsIgnoreCase("false")) {
return null;
} else {
return "Value must be a Boolean value (\"true\" or \"false\")";
}
}
@Override
public String getName() {
return "Show-Measure";
}
@Override
public Object unmarshal(String s) {
return Boolean.valueOf(s);
}
}
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.bmotionstudio.gef.editor.figure;
import org.eclipse.draw2d.BorderLayout;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.RectangleFigure;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.PaletteData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
public class CanisterFigure extends AbstractBMotionFigure {
private RectangleFigure axisRect;
private Figure axisFigure;
private RectangleFigure fillRect;
private Figure fillFigure;
private Image layerImage;
private ImageData imageData;
private int fill_height;
private double positions;
private int show_pos;
private Boolean showMeasure;
public CanisterFigure() {
XYLayout layout = new XYLayout();
setLayoutManager(layout);
PaletteData palette = new PaletteData(
new RGB[] { ColorConstants.white.getRGB() });
imageData = new ImageData(1, 1, 8, palette);
imageData.alpha = 255;
imageData.setPixel(0, 0, 0);
layerImage = new Image(null, imageData);
axisFigure = new Figure();
axisFigure.setLocation(new Point(0, 0));
axisFigure.setLayoutManager(new XYLayout());
add(axisFigure);
fillFigure = new Figure();
fillFigure.setLayoutManager(new BorderLayout());
add(fillFigure);
fillRect = new RectangleFigure();
fillRect.setOutline(false);
fillFigure.add(fillRect);
fillFigure.setConstraint(fillRect, BorderLayout.BOTTOM);
setOpaque(true);
}
public void setLayout(Rectangle rect) {
getParent().setConstraint(this, rect);
// Set the right size and position of the y-axis
axisFigure.removeAll();
int fillPos = 0;
double one_pos = Double.valueOf(rect.height) / positions;
if (showMeasure) {
axisFigure.setSize(100, rect.height);
axisRect = new RectangleFigure();
axisFigure.add(axisRect);
axisRect.setBackgroundColor(ColorConstants.black);
axisFigure.setConstraint(axisRect, new Rectangle(14, 0, 1,
rect.height));
RectangleFigure line;
Label lb;
for (int i = 0; i <= positions; i = i + show_pos) {
lb = new Label();
axisFigure.add(lb);
lb.setText(String.valueOf((int) (positions - i)));
lb.setBackgroundColor(ColorConstants.red);
lb.setTextAlignment(PositionConstants.LEFT);
if (i == 0) {
axisFigure.setConstraint(lb, new Rectangle(18,
(int) (i * one_pos), 30, 10));
} else if (i == positions) {
axisFigure.setConstraint(lb, new Rectangle(18,
(int) (i * one_pos) - 10, 30, 10));
} else {
axisFigure.setConstraint(lb, new Rectangle(18,
(int) (i * one_pos) - 5, 30, 10));
}
line = new RectangleFigure();
line.setBackgroundColor(ColorConstants.black);
line.setOutline(false);
axisFigure.add(line);
if (i == positions) {
axisFigure.setConstraint(line, new Rectangle(10,
(int) (i * one_pos) - 1, 10, 1));
} else {
axisFigure.setConstraint(line, new Rectangle(10,
(int) (i * one_pos), 10, 1));
}
}
fillPos = 60;
}
// Set right size of the fill figure
setConstraint(fillFigure, new Rectangle(fillPos, 0, rect.width
- fillPos, rect.height));
double tmp = one_pos * (positions - Double.valueOf(fill_height));
int f_fill_height = (int) tmp;
fillRect.setSize(rect.width - fillPos, rect.height - f_fill_height);
fillFigure.setConstraint(fillRect, BorderLayout.BOTTOM);
fillFigure.repaint();
}
public void setAlpha(int alpha) {
imageData.alpha = alpha;
if (layerImage != null && !layerImage.isDisposed()) {
layerImage.dispose();
}
layerImage = new Image(null, imageData);
repaint();
}
public void paintFigure(Graphics g) {
Rectangle rectangle = getClientArea();
g.drawImage(layerImage, new Rectangle(layerImage.getBounds()),
rectangle);
}
public void setFillColor(RGB rgb) {
fillRect.setBackgroundColor(new Color(Display.getDefault(), rgb));
}
public void setFillHeight(Integer height) {
this.fill_height = height;
}
public void setMaxPos(Integer maxPos) {
this.positions = maxPos;
}
public void setInterval(Integer interval) {
this.show_pos = interval;
}
public void setMeasure(Boolean bol) {
this.showMeasure = bol;
}
public void setBackgroundColor(RGB rgb) {
imageData.palette.colors[0] = rgb;
if (layerImage != null && !layerImage.isDisposed()) {
layerImage.dispose();
}
layerImage = new Image(null, imageData);
repaint();
}
}
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.bmotionstudio.gef.editor.part;
import java.beans.PropertyChangeEvent;
import org.eclipse.draw2d.IFigure;
import org.eclipse.swt.graphics.RGB;
import de.bmotionstudio.gef.editor.AttributeConstants;
import de.bmotionstudio.gef.editor.figure.CanisterFigure;
import de.bmotionstudio.gef.editor.model.BControl;
public class BCanisterPart extends AppAbstractEditPart {
@Override
protected IFigure createEditFigure() {
IFigure figure = new CanisterFigure();
return figure;
}
@Override
public void refreshEditFigure(IFigure figure, BControl model,
PropertyChangeEvent evt) {
((CanisterFigure) figure).setAlpha(Integer.valueOf(model
.getAttributeValue(AttributeConstants.ATTRIBUTE_ALPHA)
.toString()));
((CanisterFigure) figure).setFillColor((RGB) model
.getAttributeValue(AttributeConstants.ATTRIBUTE_FILL_COLOR));
((CanisterFigure) figure).setFillHeight(Integer.valueOf(model
.getAttributeValue(AttributeConstants.ATTRIBUTE_FILL_HEIGHT)
.toString()));
((CanisterFigure) figure).setMaxPos(Integer.valueOf(model
.getAttributeValue(AttributeConstants.ATTRIBUTE_MEASURE_MAXPOS)
.toString()));
((CanisterFigure) figure).setInterval(Integer.valueOf(model
.getAttributeValue(
AttributeConstants.ATTRIBUTE_MEASURE_INTERVAL)
.toString()));
((CanisterFigure) figure).setMeasure(Boolean.valueOf(model
.getAttributeValue(AttributeConstants.ATTRIBUTE_SHOWS_MEASURE)
.toString()));
((CanisterFigure) figure)
.setBackgroundColor((RGB) model
.getAttributeValue(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR));
}
@Override
protected void prepareEditPolicies() {
}
@Override
protected void prepareRunPolicies() {
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment