Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: javafx
    • Environment:

      Windows 7, javaFX 1.2 SDK, NetBeans 6.5.1

      Description

      Hello.
      Excuse me, I can't determine component and version. I'm using JavaFX SDK 1.2 on Windows7, Intel.
      I'm trying to create custom node which presents tool line (like in Photoshop) with pointer, selection tool, brush tool, e.t.c.
      Each "tool" is an ImageView with two Images. One image for inactive state, second image is for active state.


      Here is the code:

      1. Main.fx
      package ru.afx.client.main;

      import javafx.stage.Stage;
      import javafx.scene.Scene;

      import ru.afx.client.tool.ToolLineController;

      var scene: Scene = Scene{};
      insert ToolLineController.getTools() into scene.content;

      Stage{
          title: "AnimateFX"
          width: 800
          height: 300
          scene: scene
      };


      2. ToolLineController
      package ru.afx.client.tool;

      import javafx.scene.Group;
      import ru.afx.client.tool.AbstractTool;
      import javafx.scene.CustomNode;
      import javafx.scene.Node;
      import ru.afx.client.tool.concrete.Pointer;

      /**
       * @author SSheypak
       * Class represents container with main tools kept inside
       */
      class ToolLine extends CustomNode{
          public var tools: AbstractTool[];

          public override function create(): Node{
              tools = [Pointer{}]; //seq with tools
              return
              Group{content: tools};
          }

      }

      def toolLine = ToolLine{}; //single tool line

      /**@return single ToolLine instance*/
      public function getToolLine() :ToolLine{
          return toolLine;
      }

      /** A way to modify default tools list
      * @return modifyable sequence with tools
      */
      public function getTools(): AbstractTool[]{
          return toolLine.tools;
      }


      3. AbstractTool
      package ru.afx.client.tool;

      import javafx.scene.CustomNode;
      import javafx.scene.Node;
      import javafx.scene.image.ImageView;
      import javafx.scene.image.Image;
      import javafx.scene.input.MouseEvent;

      /**
       * @author SSheypak
       */

      public abstract class AbstractTool extends CustomNode{
          public var title: String; //tooltip

          public var activeImageUrl: String; //when tool is in action
          public var inactiveImageUrl: String;//when tool is released
          var activeImage: Image; //when tool is in action
          var inactiveImage: Image;//when tool is released

          var tools: AbstractTool[]; //additional tools, for example brush tool allows to choose color of brush and size of brush

          /**This function returns Additional tools line.
          * Subclasses must define how does additional tools will look like.
          * @return Node with additional tools
          */
          public abstract function getAdditionalToolLine(): Node;



          public override function create():Node {
              activeImage = Image{
                  url: activeImageUrl;
              }
              inactiveImage = Image{
                  url: inactiveImageUrl;
              }


              return
              ImageView{
                  image: inactiveImage;
                  onMouseClicked: function(me:MouseEvent):Void { //just show appropriate image.
                      if( (me.node as ImageView).image == inactiveImage ){
                          (me.node as ImageView).image = activeImage;
                      }else{
                          (me.node as ImageView).image = inactiveImage;
                      }
                  }

              }
          }
      }

      3. Pointer.fx
      package ru.afx.client.tool.concrete;

      import javafx.scene.Node;
      import ru.afx.client.tool.AbstractTool;

      public class Pointer extends AbstractTool{
          init{
              println("Pointer path=[{__DIR__}]");
          }
          
          public override var title = "Pointer"; //tooltip
          public override var activeImageUrl = "{__DIR__}/ru/afx/client/resource/pointer_active"; //when tool is in action
          public override var inactiveImageUrl = "{__DIR__}/ru/afx/client/resource/pointer_inactive";//when tool is released

       public override function getAdditionalToolLine(): Node{
           null;
       }
      }

      And error:
      init:
      deps-jar:
      init:
      deps-jar:
      compile:
      jar:
      compile:
      jar:
      standard-run:
      Pointer path=[jar:file:/E:/DEVELOPMENT/AFX_prj/AFXClient/dist/AFXClient.jar!/ru/afx/client/tool/concrete/]
      WARNING * WARNING * WARNING * WARNING * WARNING
      An attempt has been made to add node to a new group without
      first removing it from its current group. See the class
      documentation for javafx.scene.Node for further information.
      This request will be granted temporarily but it will
      be refused in the future. Please change your code now.
      node=Pointer oldgroup=Group newgroup=Group
      Stack trace follows.
      java.lang.IllegalArgumentException
              at javafx.scene.Group$_SBECL.onChange(Group.fx:162)
              at com.sun.javafx.runtime.location.SequenceVariable.notifyListeners(SequenceVariable.java:157)
              at com.sun.javafx.runtime.location.SequenceVariable.setAsSequence(SequenceVariable.java:259)
              at com.sun.javafx.runtime.location.SequenceVariable.set(SequenceVariable.java:222)
              at com.sun.javafx.runtime.location.SequenceVariable.set(SequenceVariable.java:39)
              at com.sun.javafx.runtime.location.Bindings$BijectiveBinding$2.onChange(Bindings.java:156)
              at com.sun.javafx.runtime.location.AbstractLocation$1.onAction(AbstractLocation.java:220)
              at com.sun.javafx.runtime.location.AbstractLocation$1.onAction(AbstractLocation.java:217)
              at com.sun.javafx.runtime.location.AbstractLocation.iterateChildren(AbstractLocation.java:182)
              at com.sun.javafx.runtime.location.AbstractLocation.invalidateDependencies(AbstractLocation.java:254)
              at com.sun.javafx.runtime.location.SequenceVariable.notifyListeners(SequenceVariable.java:150)
              at com.sun.javafx.runtime.location.SequenceVariable.setAsSequence(SequenceVariable.java:259)
              at com.sun.javafx.runtime.location.SequenceVariable.replaceSlice(SequenceVariable.java:346)
              at com.sun.javafx.runtime.location.SequenceVariable.insert(SequenceVariable.java:448)
              at ru.afx.client.main.Main.javafx$run$(Main.fx:17)
              at ru.afx.client.main.Main.javafx$run$(Main.fx:17)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at com.sun.javafx.runtime.provider.GUIRuntimeProvider$1.run(GUIRuntimeProvider.java:65)
              at com.sun.javafx.tk.swing.SwingToolkit$StartupRoutine.run(SwingToolkit.fx:593)
              at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
              at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
              at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
      browser-run:
      jws-run:
      midp-run:
      run:
      BUILD SUCCESSFUL (total time: 6 seconds)

        Attachments

          Activity

            People

            • Assignee:
              kcr Kevin Rushforth
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: