Package jsynoptic.ui

Examples of jsynoptic.ui.LongAction


     *
     * @param shapes
     */
    protected void doPropertiesAction(List shapes){
       
        new LongAction(LongAction.LONG_ACTION_SHAPE, shapes, this) {
            protected void doAction() {
               
                List shapes = (List)param;
               
                // Get the set of properties which can be applied to the selection
View Full Code Here


    // primary/secondary => no code dup
    protected boolean setX(DataSource ds, boolean primary, boolean background) {
        if (ds==null) return false;

        if (background){
            new LongAction(LongAction.LONG_ACTION_SHAPE | LongAction.LONG_ACTION_SOURCE,
                    new Object[]{ds, new Boolean(primary), new Boolean(background)},
                    new Object[]{ds, this} ){

                protected void doAction() {
View Full Code Here

    }

    protected boolean addY(DataSource ds, boolean primary, boolean usePrimaryX, boolean background) {
        if (ds==null) return false;

        new LongAction(LongAction.LONG_ACTION_SHAPE | LongAction.LONG_ACTION_SOURCE,
                new Object[]{ds, new Boolean(primary), new Boolean(usePrimaryX)},
                new Object[]{ds, this} ) {

            protected void doAction() {
View Full Code Here

            repaintDiagram(getBounds());
            return true;
        }
       
        if (action.equals(resources.getStringValue("properties"))) {    
            new LongAction(LongAction.LONG_ACTION_SHAPE, null, this) {
                protected void doAction() {
                    JPropertiesPanel panel=createPanel();

                    /** Only one shape properties dialog box can be displayed at once
                     * When user opens a dialog box properties while another one is still displayed: this last dislaog box is closed
                     */
                    Point oldLocation=null;
                    if (currentDialogBox!=null){
                        oldLocation= currentDialogBox.getBounds().getLocation();
                        currentDialogBox.dispose();
                    }
                    ArrayList shapes = new ArrayList();
                    shapes.add(Plot.this);
                    PlotPropertiesDialogBox optionDialog = new PlotPropertiesDialogBox(JSynoptic.gui.getOwner(), panel, panel.getShapeName(), shapes);

                    if (oldLocation!=null)
                        optionDialog.setLocation(oldLocation);

                    currentDialogBox = optionDialog;
                    optionDialog.show();
                }
            }.start();
            return true;
        }

        if (action.startsWith(resources.getStringValue("adjustOnX"))) {
            if (o instanceof Double[]){
                HashMap oldValues=getAxesProperties(null, -1);

                Double[] xranges = ((Double[])o);

                axesLimitsArray[PX].min = xranges[0].doubleValue();
                axesLimitsArray[PX].max = xranges[1].doubleValue();
                axesLimitsArray[PX].step = computeStep(axesLimitsArray[PX].min, axesLimitsArray[PX].max, preferredXGraduation);

                if ( (xranges[2] != null) && (_asx2 != null)) {
                    axesLimitsArray[SX].min = xranges[2].doubleValue();
                    axesLimitsArray[SX].max = xranges[3].doubleValue();
                    axesLimitsArray[SX].step = computeStep(axesLimitsArray[SX].min, axesLimitsArray[SX].max, preferredXGraduation);
                }

                repaintDiagram(getBounds());


                PlotCompoundEdit ce=new PlotCompoundEdit(oldValues);
                if(undoableEdit != null){
                    undoableEdit.addEdit(ce);
                }
                return true;
            } else {
                return false;
            }


        }
        if (action.equals(resources.getStringValue("autoscale"))) {
            // get the old values for the 4 axes
            HashMap oldValues=getAxesProperties(null, -1);

            for(int i =0; i< AXE_NUMBER;i++){
                axesLimitsArray[i].validity = false;
            }
            repaintDiagram(getBounds());

            PlotCompoundEdit ce=new PlotCompoundEdit(oldValues);
            if(undoableEdit != null){
                undoableEdit.addEdit(ce);
            }
            return true;
        }
        if (action.equals(resources.getStringValue("autoscaleOnY"))) {
            // get the old values for the 4 axes
            HashMap oldValues=getAxesProperties(null, -1);

            // auto-scale on primary Y
            axesLimitsArray[PY].validity = false;

            // auto-scale on secondary Y
            axesLimitsArray[SY].validity = false;

            repaintDiagram(getBounds());

            PlotCompoundEdit ce=new PlotCompoundEdit(oldValues);
            if(undoableEdit != null){
                undoableEdit.addEdit(ce);
            }
            return true;
        }

        if (o instanceof DataSource) {
            boolean res = false;

            DataSource ds = (DataSource)o;
            if (action.equals(resources.getStringValue("setX"))) {

                res =  setPrimaryX(ds, true);

            }
            if (action.equals(resources.getStringValue("addY"))) {

                res =  addPrimaryY(ds, true);


            }
            if (action.equals(resources.getStringValue("addYSecX"))) {

                res =  addPrimaryYForSecondaryX(ds, true);

            }
            if (action.equals(resources.getStringValue("addSecY"))) {

                res =  addSecondaryY(ds, true);

            }
            if (action.equals(resources.getStringValue("setSecX"))) {

                res =  setSecondaryX(ds, true);

            }
            if (action.equals(resources.getStringValue("addSecYSecX"))) {

                res =  addSecondaryYForSecondaryX(ds, true);

            }

            return res;
        }

        if (o instanceof DataSourceCollection) {
            DataSourceCollection dsc = (DataSourceCollection)o;
            if (action.equals(resources.getStringValue("setXY1Yn"))) {
                if (dsc.size()<1) return false;
                new LongAction(0, new Object[] {dsc,action}) {
                    protected void doAction() {
                        DataSourceCollection dsc = (DataSourceCollection)((Object[])param)[0];
                        setPrimaryX((DataSource)dsc.get(0), false);
                        boolean hasValues = axesLimitsArray[PY].validity;
                        axesLimitsArray[PY].validity = true; // compute only once all curve are inserted
                        for (int i=1; i<dsc.size()-1; i++)
                            addPrimaryY((DataSource)dsc.get(i), false);
                        axesLimitsArray[PY].validity = hasValues;
                        if (dsc.size()>1) addPrimaryY((DataSource)dsc.get(dsc.size()-1), false);
                        Rectangle bounds = getBounds();
                        setTitle(DataInfo.getLabel(dsc));
                        repaintDiagram(bounds);
                    }
                }.start();
                return false;
            }

            if (action.equals(resources.getStringValue("addY1Yn"))) {
                if (dsc.size()<1) return false;
                new LongAction(0, new Object[] {dsc,action}) {
                    protected void doAction() {
                        DataSourceCollection dsc = (DataSourceCollection)((Object[])param)[0];
                        boolean hasValues = axesLimitsArray[PY].validity;
                        axesLimitsArray[PY].validity = true; // compute only once all curve are inserted
                        for (int i=0; i<dsc.size()-1; i++)
                            addPrimaryY((DataSource)dsc.get(i), false);
                        axesLimitsArray[PY].validity = hasValues;
                        if (dsc.size()>0) addPrimaryY((DataSource)dsc.get(dsc.size()-1), false);
                        Rectangle bounds = getBounds();
                        repaintDiagram(bounds);
                    }
                }.start();
                return false;
            }

            if (action.equals(resources.getStringValue("addSecY1Yn"))) {
                if (dsc.size()<1) return false;
                new LongAction(0, new Object[] {dsc,action}) {
                    protected void doAction() {
                        DataSourceCollection dsc = (DataSourceCollection)((Object[])param)[0];
                        boolean hasValues = axesLimitsArray[SY].validity;
                        boolean hasLabel = (axesLimitsArray[SY].label!=null);
                        axesLimitsArray[SY].validity = true; // compute only once all curve are inserted
                        for (int i=0; i<dsc.size()-1; i++)
                            addSecondaryY((DataSource)dsc.get(i), false);
                        axesLimitsArray[SY].validity = hasValues;
                        if (dsc.size()>0) addSecondaryY((DataSource)dsc.get(dsc.size()-1), false);
                        Rectangle bounds = getBounds();
                        if ((!hasLabel) && (dsc.size()>1)) {axesLimitsArray[SY].label = null; setLegendVisible(true);}
                        repaintDiagram(bounds);
                    }
                }.start();
                return false;
            }

            if (action.equals(resources.getStringValue("setSecXY1Yn"))) {
                if (dsc.size()<1) return false;
                new LongAction(0, new Object[] {dsc,action}) {
                    protected void doAction() {
                        DataSourceCollection dsc = (DataSourceCollection)((Object[])param)[0];
                        setSecondaryX((DataSource)dsc.get(0), false);
                        boolean hasValues = axesLimitsArray[SY].validity;
                        boolean hasLabel = (axesLimitsArray[SY].label!=null);
                        axesLimitsArray[SY].validity = true; // compute only once all curve are inserted
                        for (int i=1; i<dsc.size()-1; i++)
                            addSecondaryY((DataSource)dsc.get(i), false);
                        axesLimitsArray[SY].validity = hasValues;
                        if (dsc.size()>1) addSecondaryY((DataSource)dsc.get(dsc.size()-1), false);
                        Rectangle bounds = getBounds();
                        if ((!hasLabel) && (dsc.size()>2)) {axesLimitsArray[SY].label = null; setLegendVisible(true);}
                        repaintDiagram(bounds);
                    }
                }.start();
                return false;
            }

            if (action.equals(resources.getStringValue("addSecY1YnForSecX"))) {
                if (dsc.size()<1) return false;
                new LongAction(0, new Object[] {dsc,action}) {
                    protected void doAction() {
                        DataSourceCollection dsc = (DataSourceCollection)((Object[])param)[0];
                        boolean hasValues = axesLimitsArray[SY].validity;
                        boolean hasLabel = (axesLimitsArray[SY].label!=null);
                        axesLimitsArray[SY].validity = true; // compute only once all curve are inserted
View Full Code Here

 
  public boolean doAction(double x, double y, Object o, String action, CompoundEdit undoableEdit) {

    // bind is selected, so try it!
    if (action.equals("Bind to Socket")) {
      new LongAction(LongAction.LONG_ACTION_SOURCE,this) {
        protected void doAction() {
          String input= JOptionPane.showInputDialog(null, "Enter a port number to open (e.g. 4444)\n(Opening will be done with a timeout after clicking on OK):","4444");
          if (input != null) {
            int portNumber= Integer.parseInt(input);
            try {       
View Full Code Here

TOP

Related Classes of jsynoptic.ui.LongAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.