use of org.eclipse.draw2d.Shape in project yamcs-studio by yamcs.
the class WidgetConnectionEditPart method activate.
@Override
public void activate() {
if (!isActive()) {
super.activate();
getWidgetModel().getProperty(ConnectionModel.PROP_LINE_COLOR).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
getConnectionFigure().setForegroundColor(((OPIColor) evt.getNewValue()).getSWTColor());
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_LINE_STYLE).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
getConnectionFigure().setLineStyle(getWidgetModel().getLineStyle());
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_LINE_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
getConnectionFigure().setLineWidth(getWidgetModel().getLineWidth());
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_ROUTER).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updateRouter(getConnectionFigure());
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_POINTS).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent evt) {
if (getViewer() == null || getViewer().getControl() == null) {
return;
}
Runnable runnable = new Runnable() {
@Override
public void run() {
if (((PointList) evt.getOldValue()).size() != ((PointList) evt.getNewValue()).size())
updateRouter(getConnectionFigure());
else
refreshBendpoints(getConnectionFigure());
}
};
// It should update at the same rate as other widget at run time
if (getExecutionMode() == ExecutionMode.RUN_MODE) {
Display display = getViewer().getControl().getDisplay();
WidgetIgnorableUITask task = new WidgetIgnorableUITask(getWidgetModel().getProperty(ConnectionModel.PROP_POINTS), runnable, display);
GUIRefreshThread.getInstance(getExecutionMode() == ExecutionMode.RUN_MODE).addIgnorableTask(task);
} else
runnable.run();
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_ARROW_LENGTH).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updateArrowLength(getConnectionFigure());
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_ARROW_TYPE).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updateDecoration(getConnectionFigure());
updateArrowLength(getConnectionFigure());
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_FILL_ARROW).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updateDecoration(getConnectionFigure());
updateArrowLength(getConnectionFigure());
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_ANTIALIAS).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
getConnectionFigure().setAntialias(getWidgetModel().isAntiAlias() ? SWT.ON : SWT.OFF);
for (Object obj : getConnectionFigure().getChildren()) {
if (obj instanceof Shape)
((Shape) obj).setAntialias(getWidgetModel().isAntiAlias() ? SWT.ON : SWT.OFF);
}
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_ADD).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
getConnectionFigure().setLineJumpAdd(getWidgetModel().getLineJumpAdd());
Runnable runnable = new Runnable() {
@Override
public void run() {
getConnectionFigure().repaint();
}
};
WidgetIgnorableUITask task = new WidgetIgnorableUITask(getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_ADD), runnable, getViewer().getControl().getDisplay());
GUIRefreshThread.getInstance(getExecutionMode() == ExecutionMode.EDIT_MODE).addIgnorableTask(task);
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_SIZE).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
getConnectionFigure().setLineJumpSize(getWidgetModel().getLineJumpSize());
Runnable runnable = new Runnable() {
@Override
public void run() {
getConnectionFigure().repaint();
}
};
WidgetIgnorableUITask task = new WidgetIgnorableUITask(getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_SIZE), runnable, getViewer().getControl().getDisplay());
GUIRefreshThread.getInstance(getExecutionMode() == ExecutionMode.EDIT_MODE).addIgnorableTask(task);
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_STYLE).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
getConnectionFigure().setLineJumpStyle(getWidgetModel().getLineJumpStyle());
Runnable runnable = new Runnable() {
@Override
public void run() {
getConnectionFigure().repaint();
}
};
WidgetIgnorableUITask task = new WidgetIgnorableUITask(getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_SIZE), runnable, getViewer().getControl().getDisplay());
GUIRefreshThread.getInstance(getExecutionMode() == ExecutionMode.EDIT_MODE).addIgnorableTask(task);
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_IS_LOADED_FROM_LINKING_CONTAINER).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updateRouter(getConnectionFigure());
}
});
}
}
use of org.eclipse.draw2d.Shape in project yamcs-studio by yamcs.
the class AbstractFixRatioSizeFeedbackFactory method getSizeOnDropFeedback.
/**
* Lazily creates and returns the Figure to use for size-on-drop feedback.
*
* @return the size-on-drop feedback figure
*/
protected Shape getSizeOnDropFeedback() {
if (sizeOnDropFeedback == null) {
sizeOnDropFeedback = new RectangleFigure();
FigureUtilities.makeGhostShape((Shape) sizeOnDropFeedback);
((Shape) sizeOnDropFeedback).setLineStyle(Graphics.LINE_DASHDOT);
sizeOnDropFeedback.setForegroundColor(ColorConstants.white);
}
return sizeOnDropFeedback;
}
use of org.eclipse.draw2d.Shape in project yamcs-studio by yamcs.
the class AbstractShapeEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
// line width
IWidgetPropertyChangeHandler lineWidthHandler = new IWidgetPropertyChangeHandler() {
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
Shape shape = (Shape) refreshableFigure;
if (((Integer) newValue).equals(0))
shape.setOutline(false);
else {
shape.setOutline(true);
shape.setLineWidth((Integer) newValue);
}
return true;
}
};
setPropertyChangeHandler(AbstractShapeModel.PROP_LINE_WIDTH, lineWidthHandler);
// line style
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
Shape shape = (Shape) refreshableFigure;
shape.setLineStyle(LineStyle.values()[(Integer) newValue].getStyle());
return true;
}
};
setPropertyChangeHandler(AbstractShapeModel.PROP_LINE_STYLE, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (GraphicsUtil.useAdvancedGraphics())
((Shape) figure).setAntialias(((Boolean) newValue) ? SWT.ON : null);
return false;
}
};
setPropertyChangeHandler(AbstractShapeModel.PROP_ANTIALIAS, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (GraphicsUtil.useAdvancedGraphics()) {
if ((Integer) newValue < 255)
((Shape) figure).setAlpha((Integer) newValue);
else
((Shape) figure).setAlpha(null);
}
return false;
}
};
setPropertyChangeHandler(AbstractShapeModel.PROP_ALPHA, handler);
}
use of org.eclipse.draw2d.Shape in project yamcs-studio by yamcs.
the class AbstractShapeEditPart method createFigure.
@Override
protected IFigure createFigure() {
Shape shape = (Shape) super.createFigure();
AbstractShapeModel model = getWidgetModel();
shape.setOutline(model.getLineWidth() != 0);
shape.setLineWidth(model.getLineWidth());
shape.setLineStyle(model.getLineStyle());
if (GraphicsUtil.useAdvancedGraphics()) {
if (model.getAlpha() < 255)
shape.setAlpha(model.getAlpha());
else
shape.setAlpha(null);
shape.setAntialias(model.isAntiAlias() ? SWT.ON : null);
}
return shape;
}
use of org.eclipse.draw2d.Shape in project yamcs-studio by yamcs.
the class WidgetXYLayoutEditPolicy method createSizeOnDropFeedback.
/**
* Override to provide custom feedback figure for the given create request.
*
* @param request
* the create request
* @return custom feedback figure
*/
@Override
protected IFigure createSizeOnDropFeedback(final CreateRequest request) {
String typeId = determineTypeIdFromRequest(request);
IGraphicalFeedbackFactory feedbackFactory = WidgetsService.getInstance().getWidgetFeedbackFactory(typeId);
if (feedbackFactory != null) {
Shape feedbackFigure = feedbackFactory.createSizeOnDropFeedback(request);
if (feedbackFigure != null) {
addFeedback(feedbackFigure);
return feedbackFigure;
}
}
return super.createSizeOnDropFeedback(request);
}
Aggregations