reusetool n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
ReuseTool PowerPoint Presentation
Download Presentation
ReuseTool

Loading in 2 Seconds...

play fullscreen
1 / 11

ReuseTool - PowerPoint PPT Presentation


  • 84 Views
  • Uploaded on

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 {

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'ReuseTool' - kent


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
reusetool

ReuseTool

Auxiliando o Processo de Instanciação

c digo i
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);
  • }
  • }
c digo ii
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));
  • };
  • }
hotspots
Hotspots
  • Configurando a Forma
    • Ícones
    • Aparência
    • Conexões
  • Alterando a Palette
    • Inserindo novo elemento na Palette
a solu o rdl
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