Ejemplo n.º 1
0
 private void jMenuItem22ActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenuItem22ActionPerformed
   // TODO add your handling code here:
   Service s = new Service();
   s.setVisible(true);
   setVisible(false);
 } // GEN-LAST:event_jMenuItem22ActionPerformed
Ejemplo n.º 2
0
 void updateServiceList(TreeNode parentNode, Device device) {
   ServiceList serviceList = device.getServiceList();
   int nServices = serviceList.size();
   for (int n = 0; n < nServices; n++) {
     Service service = serviceList.getService(n);
     String serviceType = service.getServiceType();
     TreeNode serviceNode = new TreeNode(serviceType);
     serviceNode.setUserData(service);
     parentNode.add(serviceNode);
     updateActionList(serviceNode, service);
     updateStateVariableList(serviceNode, service);
   }
 }
Ejemplo n.º 3
0
 void updateStateVariableList(TreeNode parentNode, Service service) {
   ServiceStateTable stateList = service.getServiceStateTable();
   int nStateVariables = stateList.size();
   for (int n = 0; n < nStateVariables; n++) {
     StateVariable state = stateList.getStateVariable(n);
     String stateName = state.getName();
     TreeNode stateNode = new TreeNode(stateName);
     stateNode.setUserData(state);
     parentNode.add(stateNode);
   }
 }
Ejemplo n.º 4
0
 void updateActionList(TreeNode parentNode, Service service) {
   ActionList actionList = service.getActionList();
   int nActions = actionList.size();
   for (int n = 0; n < nActions; n++) {
     Action action = actionList.getAction(n);
     String actionName = action.getName();
     TreeNode actionNode = new TreeNode(actionName);
     actionNode.setUserData(action);
     parentNode.add(actionNode);
     updateArgumentList(actionNode, action);
   }
 }
Ejemplo n.º 5
0
  public void init() {
    service.initDrawSpace(this);
    tool = ToolFactory.getToolInstance(this, DrawTool.PENCIL_TOOL);
    MouseMotionListener motionListener =
        new MouseMotionAdapter() {
          // 拖动鼠标
          public void mouseDragged(MouseEvent e) {
            tool.mouseDragged(e);
            canSave = true;
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
          }

          // 移动鼠标
          public void mouseMoved(MouseEvent e) {
            tool.mouseMoved(e);
          }
        };
    // 创建鼠标监听器
    MouseListener mouseListener =
        new MouseAdapter() {
          // 松开鼠标
          public void mouseReleased(MouseEvent e) {
            tool.mouseReleased(e);
            /*if(canSave){
            	BufferedImage buImg = getImg();//每次松开后保存图片
            	try {
            		ImageIO.write(buImg, "jpg", new File("c:123.jpg"));
            	} catch (IOException e1) {
            		// TODO Auto-generated catch block
            		e1.printStackTrace();
            	}
            	if(Service.count != maxGraphicsCount){
            		Service.canvasImg.add(buImg);
            		Service.count++;

            	}
            	else{
            		Service.canvasImg.remove(0);//如果保存的对象超出了设置的最大值,则从list中删除一个最早放入的
            		Service.canvasImg.add(buImg);
            	}
            }*/
            canSave = false;
          }

          // 按下鼠标
          public void mousePressed(MouseEvent e) {
            tool.mousePressed(e);
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
          }

          // 点击鼠标
          public void mouseClicked(MouseEvent e) {
            tool.mouseClicked(e);
          }

          @Override
          public void mouseEntered(MouseEvent e) {
            AbstractTool.cursorIcon.setVisible(true);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            AbstractTool.cursorIcon.setVisible(false);
            remove(AbstractTool.cursorIcon);
            repaint();
          }
        };

    addMouseMotionListener(motionListener);
    addMouseListener(mouseListener);
    addComponentListener(
        new ComponentAdapter() {

          @Override
          public void componentResized(ComponentEvent e) {
            // img.setIsSaved(false);
            SaveImage temp = null;
            temp = new SaveImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
            Graphics g = temp.getGraphics();
            g.drawImage(img, 0, 0, AbstractTool.drawWidth, AbstractTool.drawHeight, null);
            setImg(temp);
            AbstractTool.drawWidth = getWidth();
            AbstractTool.drawHeight = getHeight();
            if (AbstractTool.gradientColor != null) {
              Color[] color = AbstractTool.gradientColor;
              float[] po =
                  new float[] {0.0f, 1.0f / 6, 2.0f / 6f, 3.0f / 6, 4.0f / 6, 5.0f / 6, 1.0f};
              LinearGradientPaint gradient1 =
                  new LinearGradientPaint(
                      0, 0, AbstractTool.drawWidth, AbstractTool.drawHeight, po, color);
              AbstractTool.gradient = gradient1;
            }
          }
        });
  }
Ejemplo n.º 6
0
 public void paintComponent(Graphics g) {
   // draw
   service.repaint(g, img);
 }