1 / 11

ReuseTool

ReuseTool. Auxiliando o Processo de Instanciação. Processo de Instanciação. Cenário. Framework. Aplicação. Modelo. Código I. package org.eclipse.gef.examples.shapes.mymodel /** * A crazy shape. * @author Toacy Oliveira */ public class CrazyShape extends Shape {

kent
Download Presentation

ReuseTool

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ReuseTool Auxiliando o Processo de Instanciação

  2. Processo de Instanciação Frameworks

  3. Cenário

  4. Framework

  5. Aplicação

  6. Modelo

  7. Código I • package org.eclipse.gef.examples.shapes.mymodel • /** • * A crazy shape. • * @author Toacy Oliveira • */ • public class CrazyShape extends Shape { • /** A 16x16 pictogram of a crazy shape. */ • private static final Image CRAZY_ICON = createImage("icons/crazy16.gif"); • private static final long serialVersionUID = 1; • public Image getIcon() { • return CRAZY_ICON; • } • public String toString() { • return "Crazy " + hashCode(); • } • public IFiguregetFigure() { • return new CrazyFigure ("Pop"); • } • public ConnectionAnchorgetConnectionAnchor(IFigureiFigure) { • return new ChopboxAnchor(iFigure); • } • public booleancanConnect(Shape target) { • return (super.canConnect(target)) && !(target instanceofRectangularShape); • } • }

  8. Código II • package org.eclipse.gef.examples.shapes.myfigures; • public class CrazyFigure extends RoundedRectangle { • public CrazyFigure(String name) { • super(); • ToolbarLayout layout = new ToolbarLayout(); • setLayoutManager(layout); • setBorder(new LineBorder(ColorConstants.black, 1)); • setBackgroundColor(ColorConstants.red); • setForegroundColor(ColorConstants.yellow); • setOpaque(true); • Label l = new Label("Crazy!" + name); • l.setForegroundColor(ColorConstants.red); • l.setBackgroundColor(ColorConstants.blue); • l.setFont(new Font(null, "Arial", 20, SWT.BOLD)); • l.setBorder(new LineBorder(ColorConstants.black, 2)); • add(l); • } • public void paintFigure(Graphics graphics) { • super.paintFigure(graphics); • graphics.setForegroundColor(ColorConstants.orange); • graphics.setLineStyle(Graphics.LINE_SOLID); • graphics.setLineWidth(3); • Rectangle r = getBounds(); • graphics.drawLine(new Point(r.x + r.width / 2, r.y + r.height * 0.3), • new Point(r.x + r.width / 2, r.y + r.height * 0.7)); • // horizontal line • graphics.drawLine(new Point(r.x + r.width * 0.3, r.y + r.height / 2), • new Point(r.x + r.width * 0.7, r.y + r.height / 2)); • }; • }

  9. Hotspots • Configurando a Forma • Ícones • Aparência • Conexões • Alterando a Palette • Inserindo novo elemento na Palette

  10. Reuse DescriptionLanguage

  11. A Solução RDL COOKBOOK ShapesProducts RECIPE main{ packA =NEW_PACKAGE(FrameworkModel,"org.reusetool.example.myshapeseditor"); LOOP("Create another shape?") { // PREPARE Images EXTERNAL_TASK("Define 16x16 icon"); EXTERNAL_TASK("Define 24x24 icon"); // Define Shape SubClass shapeClass = CLASS_EXTENSION(Shape, packA,"?"); // Refine Abstract Methods m = METHOD_EXTENSION(Shape,shapeClass,addConnectionAnchor); ADD_CODE(shapeClass,m,"return new ChopboxAnchor(iFigure);"); m = METHOD_EXTENSION(Shape,shapeClass,getFigure); ADD_CODE(shapeClass,m,"return new IFIGURE_SUBCLASS);"); m = METHOD_EXTENSION(Shape,shapeClass,getIcon); ADD_CODE(shapeClass,m,"returncreateImage(\"NEW_SHAPE.gif\");"); // Configure Palette ADD_CODE(ShapesEditorPaletteFactory,createShapesDrawer, "component = new CombinedTemplateCreationEntry( \"NEW_SHAPE\", \"Create a NEW_SHAPE shape\", NEW_SHAPE.class, new SimpleFactory(NEW_SHAPE.class), ImageDescriptor.createFromFile(ShapesPlugin.class, \"icons/crazy16.gif\"), ImageDescriptor.createFromFile(ShapesPlugin.class, \"icons/crazy24.gif\")); componentsDrawer.add(component); • "); • // Redefine Method to treat How Connections can be handled • IF ("Add Feature - Restrict Connections?") THEN { • m = METHOD_EXTENSION(Shape,shapeClass,canConnect); • ADD_CODE(shapeClass,m,"Code that checks if the connection can be made."); • } • IF ("Add Feature - New Figure?") THEN{ • // Define Shape SubClass • figClass = CLASS_EXTENSION(Figure, packA,"?"); • m = METHOD_EXTENSION(Figure,figClass,paintFigure); • } • } • } • END_COOKBOOK

More Related