本文整理汇总了Java中org.eclipse.draw2d.Graphics类的典型用法代码示例。如果您正苦于以下问题:Java Graphics类的具体用法?Java Graphics怎么用?Java Graphics使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Graphics类属于org.eclipse.draw2d包,在下文中一共展示了Graphics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: outlineShape
import org.eclipse.draw2d.Graphics; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void outlineShape(Graphics graphics) {
Rectangle r = getBounds();
int x = r.x + getLineWidth() / 2;
int y = r.y + getLineWidth() / 2;
int w = r.width - Math.max(1, getLineWidth());
int h = r.height - Math.max(1, getLineWidth());
Rectangle bounds = new Rectangle(x, y, w, h);
Point topRight1 = bounds.getTopRight().translate(0, RETURN_WIDTH);
Point topRight2 = bounds.getTopRight().translate(-RETURN_WIDTH, 0);
Point topRight3 = bounds.getTopRight().translate(-RETURN_WIDTH,
RETURN_WIDTH);
graphics.drawLine(bounds.getTopLeft(), bounds.getBottomLeft());
graphics.drawLine(bounds.getBottomLeft(), bounds.getBottomRight());
graphics.drawLine(bounds.getBottomRight(), topRight1);
graphics.drawLine(topRight1, topRight2);
graphics.drawLine(topRight2, bounds.getTopLeft());
graphics.drawLine(topRight2, topRight3);
graphics.drawLine(topRight3, topRight1);
}
示例2: paintFigure
import org.eclipse.draw2d.Graphics; //导入依赖的package包/类
/**
* @see nexcore.tool.uml.ui.core.diagram.figure.AbstractNotationNodeFigure#paintFigure(org.eclipse.draw2d.Graphics)
*/
@Override
protected void paintFigure(Graphics graphics) {
super.paintFigure(graphics);
graphics.drawRectangle(getLocation().x, getLocation().y, getSize().width - 1, getSize().height - 1);
graphics.setAntialias(SWT.ON);
Rectangle bounds = getBounds();
if(isDangling()){
graphics.setForegroundColor(ColorConstants.red);
graphics.drawOval(bounds.x, bounds.y, 12, 12);
graphics.drawLine(bounds.x + 2, bounds.y + 2, bounds.x + 10, bounds.y + 10);
graphics.drawLine(bounds.x + 10, bounds.y + 2, bounds.x + 2, bounds.y + 10);
}
}
示例3: paintClientArea
import org.eclipse.draw2d.Graphics; //导入依赖的package包/类
@Override
protected void paintClientArea ( final Graphics graphics )
{
if ( this.renderer != null )
{
final Draw2DGraphics g = new Draw2DGraphics ( graphics, this.resourceManager.getDevice () );
try
{
this.renderer.paint ( g );
}
finally
{
g.dispose ();
}
}
}
示例4: TextController
import org.eclipse.draw2d.Graphics; //导入依赖的package包/类
public TextController ( final FigureCanvas canvas, final SymbolController controller, final Text element, final ResourceManager manager )
{
super ( controller, manager );
this.canvas = canvas;
this.figure = new Label ( element.getText ()) {
@Override
public void addNotify ()
{
super.addNotify ();
start ();
}
@Override
protected void paintFigure ( final Graphics graphics )
{
final Double alpha = getAlpha ();
if ( alpha != null )
{
graphics.setAlpha ( (int) ( Math.max ( 0.0, Math.min ( 1.0, alpha ) ) * 255.0 ) );
}
super.paintFigure ( graphics );
}
@Override
public void removeNotify ()
{
stop ();
super.removeNotify ( );
}
};
controller.addElement ( element, this );
applyCommon ( element );
}
示例5: outlineShape
import org.eclipse.draw2d.Graphics; //导入依赖的package包/类
/**
* @see Shape#outlineShape(Graphics)
*/
@Override
protected void outlineShape ( final Graphics graphics )
{
final float lineInset = Math.max ( 1.0f, getLineWidthFloat () ) / 2.0f;
final int inset1 = (int)Math.floor ( lineInset );
final int inset2 = (int)Math.ceil ( lineInset );
final Rectangle r = Rectangle.SINGLETON.setBounds ( getBounds () );
r.x += inset1;
r.y += inset1;
r.width -= inset1 + inset2;
r.height -= inset1 + inset2;
graphics.drawRectangle ( r );
}
示例6: paintFigure
import org.eclipse.draw2d.Graphics; //导入依赖的package包/类
@Override protected void paintFigure(Graphics graphics) {
Rectangle r = getBounds().getCopy();
Object tempEllipse = new Rectangle(0, 0, r.width, r.height);
if ( constraintRectangle==null || !constraintRectangle.equals(tempEllipse)) {
constraintRectangle = tempEllipse;
setConstraint(ellipse, constraintRectangle);
ellipse.invalidate();
}
Object tempName = new Rectangle(0, 0, r.width, r.height);
if (constraintName==null || !constraintName.equals(tempName)) {
constraintName = tempName;
setConstraint(name, constraintName);
name.invalidate();
}
}
示例7: paintFigure
import org.eclipse.draw2d.Graphics; //导入依赖的package包/类
@Override protected void paintFigure(Graphics graphics) {
Rectangle r = getBounds().getCopy();
Object tempRectangle = new Rectangle(0, 0, r.width, r.height);
if ( constraintRectangle==null || !constraintRectangle.equals(tempRectangle)) {
constraintRectangle = tempRectangle;
setConstraint(rectangle, constraintRectangle);
rectangle.invalidate();
}
Object tempName = new Rectangle(0, 0, r.width, r.height);
if (constraintName==null || !constraintName.equals(tempName) || isStateUpdate()) {
constraintName = tempName;
setConstraint(name, constraintName);
name.invalidate();
}
if (vertextStateFigure!=null) {
if (constraintStateFigure==null || !constraintStateFigure.equals(r) || isStateUpdate()) {
constraintStateFigure = r;
setStateUpdate(false);
vertextStateFigure.setConstraint(r);
vertextStateFigure.invalidate();
}
}
}
示例8: trackExecution
import org.eclipse.draw2d.Graphics; //导入依赖的package包/类
private void trackExecution(Graphics graphics) {
Rectangle rectangle = getBounds().getCopy();
if(componentStatus!=null){
if (componentStatus.equals(ComponentExecutionStatus.BLANK)){
compStatusImage = null;
}else if (componentStatus.equals(ComponentExecutionStatus.PENDING)){
compStatusImage =ImagePathConstant.COMPONENT_PENDING_ICON.getImageFromRegistry();
}else if (componentStatus.equals(ComponentExecutionStatus.RUNNING)){
compStatusImage =ImagePathConstant.COMPONENT_RUNNING_ICON.getImageFromRegistry();
}else if (componentStatus.equals(ComponentExecutionStatus.SUCCESSFUL)){
compStatusImage =ImagePathConstant.COMPONENT_SUCCESS_ICON.getImageFromRegistry();
}else if (componentStatus.equals(ComponentExecutionStatus.FAILED)){
compStatusImage = ImagePathConstant.COMPONENT_FAILED_ICON.getImageFromRegistry();
}
}
if (compStatusImage != null) {
graphics.drawImage(compStatusImage, new Point (8, rectangle.height - 22));
}
}
示例9: drawPropertyStatus
import org.eclipse.draw2d.Graphics; //导入依赖的package包/类
/**
* Draws the status image to right corner of the component
*
* @param graphics
*/
private void drawPropertyStatus(Graphics graphics) {
Rectangle rectangle = getBounds().getCopy();
if (StringUtils.isNotBlank(getPropertyStatus()) && getPropertyStatus().equals(ValidityStatus.WARN.name())) {
statusImage = ImagePathConstant.COMPONENT_WARN_ICON.getImageFromRegistry();
} else if (StringUtils.isNotBlank(getPropertyStatus()) && getPropertyStatus().equals(ValidityStatus.ERROR.name())) {
statusImage = ImagePathConstant.COMPONENT_ERROR_ICON.getImageFromRegistry();
} else if (StringUtils.isNotBlank(getPropertyStatus()) && getPropertyStatus().equals(Constants.UPDATE_AVAILABLE)) {
statusImage = ImagePathConstant.COMPONENT_UPDATE_ICON.getImageFromRegistry();
} else if (StringUtils.isNotBlank(getPropertyStatus()) && getPropertyStatus().equals(ValidityStatus.VALID.name())){
statusImage=null;
}
logger.trace("Component has {} property status.", getPropertyStatus());
if (statusImage != null && !statusImage.isDisposed()) {
graphics.drawImage(statusImage, new Point(rectangle.width - 25, 8 + componentLabelMargin));
}
}
示例10: undo
import org.eclipse.draw2d.Graphics; //导入依赖的package包/类
@Override
public void undo() {
Iterator<Model> it = deleteLinks.iterator();
while(it.hasNext()){
Link restoreLink=(Link)it.next();
restoreLink.setLineStyle(Graphics.LINE_SOLID);
restoreLink.attachSource();
restoreLink.getSource().engageOutputPort(restoreLink.getSourceTerminal());
restoreLink.setLineStyle(Graphics.LINE_SOLID);
restoreLink.attachTarget();
restoreLink.getTarget().engageInputPort(restoreLink.getTargetTerminal());
}
}
示例11: paintFigure
import org.eclipse.draw2d.Graphics; //导入依赖的package包/类
@Override
protected void paintFigure(Graphics g) {
super.paintFigure(g);
final int LEG = 5;
Rectangle r = getBounds();
g.setLineWidth(1);
g.setForegroundColor(valid ? ColorConstants.black : PandionJConstants.Colors.ERROR);
g.drawLine(r.x, r.y, r.x, r.y+r.height-1);
g.drawLine(r.x, r.y, r.x+LEG, r.y);
g.drawLine(r.x, r.y+r.height-1, r.x+LEG, r.y+r.height-1);
g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1, r.y+r.height);
g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1-LEG, r.y);
g.drawLine(r.x+r.width-1, r.y+r.height-1, r.x+r.width-1-LEG, r.y+r.height-1);
if(!valid) {
g.setForegroundColor(PandionJConstants.Colors.ERROR);
String text = "Invalid matrix";
int textWidth = FigureUtilities.getTextWidth(text, g.getFont());
Point p = r.getLocation().translate(r.width/2 - textWidth/2, 5);
g.drawText(text, p);
}
}
示例12: paintFigure
import org.eclipse.draw2d.Graphics; //导入依赖的package包/类
@Override
protected void paintFigure(Graphics g) {
super.paintFigure(g);
Rectangle r = getBounds();
Rectangle square = new Rectangle(r.getLocation().getTranslated(0, r.height/4), new Dimension(r.width/2, r.height/2));
center = new Point(square.x + square.width/2, square.y + square.height/2);
g.setBackgroundColor(dirty ? PandionJConstants.Colors.HIGHLIGHT : PandionJConstants.Colors.VARIABLE_BOX);
g.fillRectangle(square);
g.setForegroundColor(ref.getRole() == Role.FIXED_VALUE ? PandionJConstants.Colors.CONSTANT : ColorConstants.black);
g.drawRectangle(square);
g.setBackgroundColor(error ? PandionJConstants.Colors.ERROR : ColorConstants.black);
g.fillOval(center.x-3, center.y-3, 7, 7);
if(isnull) {
g.setForegroundColor(error ? PandionJConstants.Colors.ERROR : ColorConstants.black);
Point dest = center.getTranslated(20, 0);
g.drawLine(center, dest);
g.drawLine(dest.getTranslated(-3, 5), dest.getTranslated(3, -5));
}
}
示例13: paintFigure
import org.eclipse.draw2d.Graphics; //导入依赖的package包/类
@Override
protected void paintFigure(Graphics graphics) {
Date date = editor.getCurrentSelectedDate();
if (feature.hasVersionsAtDate(date)) {
paintVersionAreaBackground(graphics);
paintConnection(graphics, HyEvolutionUtil.getValidTemporalElements(feature.getWrappedModelElement().getVersions(), date).get(0));
}
if (feature.hasAttributesAtDate(date)) {
paintAttributeAreaBackground(graphics);
}
paintNameAreaBackground(graphics);
}
示例14: paintVersionMarks
import org.eclipse.draw2d.Graphics; //导入依赖的package包/类
@Override
protected void paintVersionMarks(Graphics graphics) {
HyFeature feature = this.feature.getWrappedModelElement();
List<HyVersion> versions = feature.getVersions();
for (HyVersion version : versions) {
Rectangle versionMarkRectangle = getVersionMarkRectangle(version);
HyConfiguration selectedConfiguration = ((DwFeatureModelConfiguratorViewer)editor).getSelectedConfiguration();
if (HyConfigurationUtil.configurationSelectsVersion(selectedConfiguration, version)) {
DEDrawingUtil.drawSelection(graphics, versionMarkRectangle, this, false);
}
}
super.paintVersionMarks(graphics);
}
示例15: paintAttributeMarks
import org.eclipse.draw2d.Graphics; //导入依赖的package包/类
@Override
protected void paintAttributeMarks(Graphics graphics) {
HyFeature feature = this.feature.getWrappedModelElement();
List<HyFeatureAttribute> attributes = feature.getAttributes();
for (HyFeatureAttribute attribute : attributes) {
Rectangle attributeMarkRectangle = getAttributeMarkRectangle(attribute);
HyConfiguration selectedConfiguration = ((DwFeatureModelConfiguratorViewer)editor).getSelectedConfiguration();
for(HyConfigurationElement element : selectedConfiguration.getElements()){
if(element instanceof HyAttributeValueAssignment){
if(EcoreUtil.equals(((HyAttributeValueAssignment)element).getAttribute(), attribute)){
DEDrawingUtil.drawSelection(graphics, attributeMarkRectangle, this, false);
}
}
}
}
super.paintVersionMarks(graphics);
}