Package com.mystictri.neotexture

Examples of com.mystictri.neotexture.TextureGraphNode$ConnectionPoint


      CreateMenuItem mi = (CreateMenuItem)e.getSource();

      try {
        if (!mi.isAReplaceCall) { // insert a new Node
          Channel chan = (Channel) mi.classType.newInstance();
          addTextureNode(new TextureGraphNode(chan), mousePosition.x - desktopX, mousePosition.y - desktopY);
          repaint();
        } else { // try to replace an existing node as good as possible
          TextureGraphNode node = graph.selectedNodes.get(0);
          if (node != null) {
            TextureGraphNode newNode = new TextureGraphNode((Channel) mi.classType.newInstance());
            replaceTextureNode(node, newNode);
            repaint();
          } else {
            Logger.logWarning(this, "No node selected for replace.");
          }
        }
      } catch (InstantiationException e1) {
        e1.printStackTrace();
      } catch (IllegalAccessException e1) {
        e1.printStackTrace();
      }
    } else if (e.getSource() == newChannelInsertMenuItem) {
      if (toCopyTextureGraphNode == null) {
        Logger.logError(this, "No node copied to insert.");
      } else {
        addTextureNode(toCopyTextureGraphNode.cloneThisNode(), mousePosition.x - desktopX, mousePosition.y - desktopY);
        repaint();
      }
    } else if (e.getSource() == copyChannelMenuItem) {
      if (graph.selectedNodes.size() > 0) {
        toCopyTextureGraphNode = graph.selectedNodes.get(0).cloneThisNode();
      } else {
        Logger.logError(this, "no selection in copyChannel popup menu.");
      }
    } else if (e.getSource() == replacepasteChannelMenuItem) {
      if (toCopyTextureGraphNode == null) {
        Logger.logError(this, "No node copied to replace paste.");
      } else if (graph.selectedNodes.size() > 0) {
        replaceTextureNode(graph.selectedNodes.get(0), toCopyTextureGraphNode.cloneThisNode());
        repaint();
      } else {
        Logger.logError(this, "no selection in insert-replaceChannel popup menu.");
      }
    } else if (e.getSource() == previewChannelMenuItem) {
      if (graph.selectedNodes.size() > 0) {
        addPreviewWindow(graph.selectedNodes.get(0));
        repaint();
      }
    } else if (e.getSource() == cloneChannelMenuItem) { // --------------------------------------------------------
      if (graph.selectedNodes.size() > 0) {
        TextureGraphNode orig = graph.selectedNodes.get(0);
        TextureGraphNode n = new TextureGraphNode(Channel.cloneChannel(graph.selectedNodes.get(0).getChannel()));
        addTextureNode(n, orig.getX()+32, orig.getY()+32);
        repaint();
      } else {
        Logger.logError(this, "no selection in cloneChannel popup menu.");
      }
    } else if (e.getSource() == swapInputsChannelMenuItem) { // --------------------------------------------------------
      TextureGraphNode node = graph.selectedNodes.get(0);
      if (node != null) {
        if (node.getChannel().getNumInputChannels() < 2) return;
        ConnectionPoint p0 = node.getInputConnectionPointByChannelIndex(0);
        ConnectionPoint p1 = node.getInputConnectionPointByChannelIndex(1);
        TextureNodeConnection c0 = graph.getConnectionAtInputPoint(p0);
        TextureNodeConnection c1 = graph.getConnectionAtInputPoint(p1);
        graph.removeConnection(c0);
        graph.removeConnection(c1);
        if (c0 != null && c1 != null) {
          ConnectionPoint temp = c0.target;
          c0.target = c1.target;
          c1.target = temp;
          graph.addConnection(c0);
          graph.addConnection(c1);
        } else if (c1 != null) {
          c1.target = p0;
          graph.addConnection(c1);
        } else if (c0 != null) {
          c0.target = p1;
          graph.addConnection(c0);
        } else {
          return;
        }
        repaint();
      }
    } else if (e.getSource() == addToPresetsChannelMenuItem) { // --------------------------------------------------------
      if (graph.selectedNodes.size() > 0) {
        if (graph.selectedNodes.get(0).getChannel() instanceof Pattern)
          TextureEditor.INSTANCE.m_PatternSelector.addPatternPreset((Pattern)Channel.cloneChannel((Pattern)graph.selectedNodes.get(0).getChannel()));
        else Logger.logError(this, "Invalid action 'Add to Presets': selected node is not a pattern");
      } else Logger.logError(this, "Invalid action 'Add To Presets': no selected nodes exists.");
    } else if (e.getSource() == deleteChannelMenuItem) { // --------------------------------------------------------
      action_DeleteSelectedNodes();
    } else if (e.getActionCommand().equals("arbitraryResolutionExport")) {
      String resolution = JOptionPane.showInputDialog(this, "Specify your desried resolution (for example 1024x1024)", "What Resolution?", JOptionPane.QUESTION_MESSAGE);
      if (resolution != null && resolution.matches("\\d+x\\d+")) {
        int resX = Integer.parseInt(resolution.substring(0, resolution.indexOf('x')));
        int resY = Integer.parseInt(resolution.substring(resolution.indexOf('x') + 1, resolution.length()));
        askFileAndExportTexture(resX, resY);
      }
    } else if (e.getActionCommand().matches("\\d+x\\d+")) {
      String s = e.getActionCommand();
      int resX = Integer.parseInt(s.substring(0, s.indexOf('x')));
      int resY = Integer.parseInt(s.substring(s.indexOf('x') + 1, s.length()));
      askFileAndExportTexture(resX, resY);
    }
    else {
      // ----------------------- OpenGL ---------------------------
      if (TextureEditor.GL_ENABLED) {
        TextureGraphNode n = graph.selectedNodes.get(0);
        if (n.getChannel().chechkInputChannels()) {
          if (e.getSource() == openGLDiffuseMenuItem) {
            TextureEditor.INSTANCE.m_OpenGLPreviewPanel.setDiffuseTextureNode(n);
            repaint();
          } else if (e.getSource() == openGLNormalMenuItem) {
            TextureEditor.INSTANCE.m_OpenGLPreviewPanel.setNormalTextureNode(n);
View Full Code Here


      previewWindows.setElementAt(draggedWindow, 0);
      if (draggedWindow.doClick(mousePosition.x, mousePosition.y)) {
        draggedWindow = null;
      }
    } else {
      TextureGraphNode node = graph.getNodeAtPosition(wsX, wsY);
      if (node != null) {
        if (e.getButton() == 3) { // Popup menu for a TextureGraphNode
          if (!isNodeInSelection(node)) setSelectedNode(node);
          showSelectedChannelPopupMenu(node, e.getX(), e.getY());
        } else { // if it was not a popup we look if we clicked on a connection point or on the rest of the node
          int actionType = getActionTypeForMouseClick(wsX, wsY, node);
          if (e.isShiftDown()) { // add to selection of nodes
            addSelectedNode(node);
          } else if (actionType == 1) { // want to drag the position of the node
            if (!isNodeInSelection(node)) setSelectedNode(node);
            nodeDragging = true;
          }
          else if (actionType == 2) { // dragging from the output node of a channel
            connectionDragging = true;
            connectionSource = node.getOutputConnectionPoint();
            connectionOrigin = new Point(connectionSource.getWorldSpaceX(), connectionSource.getWorldSpaceY());
            connectionTarget = e.getPoint();
          }
          else if (actionType < 0) { // dragging an existing connection of an input away
            int index = -actionType - 1;
            TextureGraphNode.ConnectionPoint inputPoint = node.getInputConnectionPointByChannelIndex(index);
            TextureNodeConnection connection = graph.getConnectionAtInputPoint(inputPoint);
            if (connection != null) {
              graph.removeConnection(connection);
              connectionDragging = true;
              connectionSource = connection.source;
View Full Code Here

   
    //!!TODO: this notifies already on selecting a node; it should fire only when the node was actually moved
    if (nodeDragging || connectionDraggingnotifyEditChangeListener();
   
    if (connectionDragging) {
      TextureGraphNode targetPat = graph.getNodeAtPosition(wsX, wsY);
      if (targetPat != null) {
        int actionType = getActionTypeForMouseClick(wsX, wsY, targetPat);
        if (actionType < 0) { // we dragged onto an input node
          int index = -actionType - 1;
         
         
          if (e.isControlDown()) { // connect all inputs
            for (int i = 0; i < targetPat.getChannel().getNumInputChannels(); i++) {
              TextureGraphNode.ConnectionPoint ip = targetPat.getInputConnectionPointByChannelIndex(i);
              graph.addConnection(new TextureNodeConnection(connectionSource, ip));
            }
          } else { // normal single connection
            TextureGraphNode.ConnectionPoint inputPoint = targetPat.getInputConnectionPointByChannelIndex(index);
            graph.addConnection(new TextureNodeConnection(connectionSource, inputPoint));
          }
        }
      }     
    }
View Full Code Here

  int desktopX, desktopY;
 
  public class TextureGraphDropTarget extends DropTargetAdapter {

    public void drop(DropTargetDropEvent e) {
      TextureGraphNode n = new TextureGraphNode(Channel.cloneChannel(TextureEditor.INSTANCE.dragndropChannel));
      addTextureNode(n, e.getLocation().x - desktopX, e.getLocation().y - desktopY);
      repaint();
    }
View Full Code Here

TOP

Related Classes of com.mystictri.neotexture.TextureGraphNode$ConnectionPoint

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.