Ignore:
Timestamp:
05/10/18 16:04:51 (6 years ago)
Author:
davidb
Message:

Reworking of the code-base to separate logic from graphics. This version of Expeditee now supports a JFX graphics as an alternative to SWING

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/JSItem.java

    r1080 r1102  
    1919package org.expeditee.items;
    2020
    21 import java.awt.Graphics2D;
    22 import java.awt.Polygon;
    2321import java.util.LinkedList;
    2422import java.util.List;
     
    2927import javax.script.ScriptException;
    3028
    31 import org.expeditee.gui.DisplayIO;
    32 import org.expeditee.items.widgets.InteractiveWidget;
     29import org.expeditee.Util;
     30import org.expeditee.core.bounds.AxisAlignedBoxBounds;
     31import org.expeditee.gui.DisplayController;
    3332
    3433public class JSItem extends XRayable implements JSThreadable {
     
    6463   
    6564        private static Text getSauce(int width, int height) {
    66                 Text source = new Text(DisplayIO.getCurrentFrame().getNextItemID(), "@js: " + width + " " + height);
    67                 source.setParent(DisplayIO.getCurrentFrame());
     65                Text source = new Text(DisplayController.getCurrentFrame().getNextItemID(), "@js: " + width + " " + height);
     66                source.setParent(DisplayController.getCurrentFrame());
    6867                return source;
    6968        }
     
    115114
    116115        @Override
    117         public void paint(Graphics2D g) {
    118                 try {
    119                 this.invocable.invokeFunction("paint", (Object)g);
     116        public void paint(/*Graphics2D g*/) {
     117                try {
     118                        // Not sure of the consequences of changing this? cts16
     119                //this.invocable.invokeFunction("paint", (Object)g);
     120                        this.invocable.invokeFunction("paint");
    120121        } catch (Exception e) {
    121122                e.printStackTrace();
     
    130131
    131132        @Override
    132         public void updatePolygon() {
    133                 _poly = new Polygon();
    134                 _poly.addPoint(getX(), getY());
    135                 _poly.addPoint(getX() + _width, getY());
    136                 _poly.addPoint(getX() + _width, getY() + _height);
    137                 _poly.addPoint(getX(), getY() + _height);
     133        public AxisAlignedBoxBounds updateBounds()
     134        {
     135                return new AxisAlignedBoxBounds(getX(), getY(), _width, _height);
    138136        }
    139137       
     
    158156                        return;
    159157                }
    160                 String[] args = InteractiveWidget.parseArgs(text.substring(index));
     158                String[] args = Util.parseArgs(text.substring(index));
    161159                try {
    162160                        this.scriptEngine.eval("load = " + this.load);
     
    189187                newText.append(_width).append(" ").append(_height);
    190188               
    191                 String stateArgs = InteractiveWidget.formatArgs(saveArgs());
     189                String stateArgs = Util.formatArgs(saveArgs());
    192190                if (stateArgs != null) {
    193191                        newText.append(':');
     
    239237        }
    240238
     239        @Override
     240        public float getSize() {
     241                // TODO Auto-generated method stub
     242                return 0;
     243        }
     244
    241245}
Note: See TracChangeset for help on using the changeset viewer.