Пример #1
0
  /**
   * Retorna un árbol con las capas seleccionadas y sus atributos
   *
   * @return javax.swing.JList
   */
  private JTree getWriteableLayerTree() {
    ArrayList<GeopistaLayer> extractLayers =
        (ArrayList<GeopistaLayer>) blackboard.get(MobileExtractPanel01.MOBILE_WRITEABLE_LAYERS);
    writeableRootNodes = getRootLayerNodes(extractLayers);
    Vector rootVector =
        new NamedVector(
            I18N.get(
                MobileExtractPlugin.PluginMobileExtracti18n,
                MobilePluginI18NResource.MobileExtractPanel03_capasEdit),
            writeableRootNodes);
    JTree tree = new JTree(rootVector);
    tree.setFont(new Font(tree.getFont().getName(), Font.BOLD, tree.getFont().getSize()));
    CheckBoxNodeRenderer renderer = new CheckBoxNodeRenderer(Color.BLUE);
    tree.setCellRenderer(renderer);
    tree.setCellEditor(new CheckBoxNodeEditor(tree));
    tree.setEditable(true);

    //		DefaultMutableTreeNode root = new DefaultMutableTreeNode("Capas");
    //	    JTree tree = new JTree(root);
    //	    DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
    //	    DefaultMutableTreeNode chosen = null;
    //	    if(extractLayers!=null){
    //			for (int i = 0; i < extractLayers.size(); i++) {
    //				geopistaLayer = extractLayers.get(i);
    //				chosen = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
    //				if (chosen == null){
    //					chosen = root;
    //				}
    //				model.insertNodeInto(getTreeNodeFromLayer(geopistaLayer), chosen, 0);
    //			}
    //	    }

    return tree;
  }
  protected void uninstallDefaults(JTree tree) {
    tree.setFont(null);
    tree.setForeground(null);
    tree.setBackground(null);

    tree.setCellRenderer(null);
  }
Пример #3
0
  /** Creates new form HelpWindow */
  public HelpWindow() throws IOException {

    DefaultMutableTreeNode top = new DefaultMutableTreeNode("Help Topics");
    createNodes(top);

    tree = new JTree(top);
    tree.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    // Another double-click handler for opening a window containing the file contents.
    MouseAdapter treeAdapter =
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            DefaultMutableTreeNode clickedNode =
                (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            if (clickedNode == null) {
              return;
            }
            if (clickedNode.isLeaf()) {
              try {
                HelpInfo fileToRead = (HelpInfo) clickedNode.getUserObject();
                String f = fileToRead.fileURL;
                File helpfile = new File(f);
                URI helpURI = helpfile.toURI();
                URL helpURL = helpURI.toURL();
                if (helpURL != null) {
                  displayURL(helpURL);
                } else {
                  System.out.println("Couldn't find help file.");
                }
              } catch (Exception ex) {
                // Exceptions.printStackTrace(ex);
                // JOptionPane.showMessageDialog(gl.parentOwner, "Unable to open the file: " +
                // fileToRead);
              }
            }
          }
        };

    tree.addMouseListener(treeAdapter);

    initComponents();
    editorPane.setEditable(false);
    File helpfile = new File(dirPrefix + "background.html");
    URI helpURI = helpfile.toURI();
    URL helpURL = helpURI.toURL();
    if (helpURL != null) {
      displayURL(helpURL);
    } else {
      System.out.println("Couldn't find help file.");
    }

    JScrollPane scrollPane = new JScrollPane(tree);
    treePanel.add(scrollPane);
  }
  protected void installDefaults(JTree tree) {
    UIDefaults defaults = UIManager.getLookAndFeelDefaults();

    tree.setFont(defaults.getFont("Tree.font"));
    tree.setForeground(defaults.getColor("Tree.foreground"));
    tree.setBackground(defaults.getColor("Tree.background"));
    tree.setOpaque(true);

    hashColor = defaults.getColor("Tree.hash");
    rightChildIndent = defaults.getInt("Tree.rightChildIndent");
    leftChildIndent = defaults.getInt("Tree.leftChildIndent");
    rowHeight = defaults.getInt("Tree.rowHeight");
  }
Пример #5
0
  public void propertyChange(PropertyChangeEvent event) {
    debug(this + " " + "propertyChange: " + event.getSource() + " " + event.getPropertyName());

    if (event.getSource() == searchnav) {
      String changeName = event.getPropertyName();
      if (changeName.equals("helpModel")) {

        reloadData((HelpModel) event.getNewValue());

      } else if (changeName.equals("font")) {
        debug("Font change");
        Font newFont = (Font) event.getNewValue();
        searchparams.setFont(newFont);
        RepaintManager.currentManager(searchparams).markCompletelyDirty(searchparams);
        tree.setFont(newFont);
        RepaintManager.currentManager(tree).markCompletelyDirty(tree);
      }
      // changes to UI property?
    }
  }
Пример #6
0
 /**
  * constructor
  *
  * @param controller is the parent object
  * @throws Exception
  */
 public PseudoHYDC3View(PseudoHYDC3 controller) throws Exception {
   this.controller = controller;
   {
     String sFontName = "DFKai-SB2" /*"PMingLiU"*/;
     if (System.getProperty("hydc3.fontName") != null) {
       sFontName = System.getProperty("hydc3.fontName");
     }
     UIManager.put(
         "TextPane.font",
         new Font(
             sFontName,
             UIManager.getFont("TextPane.font").getStyle(),
             UIManager.getFont("TextPane.font").getSize()));
     UIManager.put(
         "List.font",
         new Font(
             sFontName,
             UIManager.getFont("List.font").getStyle(),
             UIManager.getFont("List.font").getSize()));
     UIManager.put(
         "TextField.font",
         new Font(
             sFontName,
             UIManager.getFont("TextField.font").getStyle(),
             UIManager.getFont("TextField.font").getSize()));
   }
   frame = new JFrame("漢語大詞典もどき");
   frame.setPreferredSize(new Dimension(800, 600));
   {
     JMenuBar menuBar = new JMenuBar();
     {
       JMenu menu = new JMenu("File");
       {
         JMenuItem menuItem = new JMenuItem("Exit");
         menuItem.addActionListener(
             new ActionListener() {
               @Override
               public void actionPerformed(ActionEvent event) {
                 System.exit(0);
               }
             });
         menu.add(menuItem);
       }
       menuBar.add(menu);
     }
     {
       JMenu menu = new JMenu("Help");
       {
         JMenuItem menuItem = new JMenuItem("About...");
         menuItem.addActionListener(
             new ActionListener() {
               @Override
               public void actionPerformed(ActionEvent event) {
                 JOptionPane.showMessageDialog(
                     frame,
                     "漢語大詞典もどき  version 0.1  by Beu",
                     "about",
                     JOptionPane.INFORMATION_MESSAGE);
               }
             });
         menu.add(menuItem);
       }
       menuBar.add(menu);
     }
     frame.setJMenuBar(menuBar);
     JPanel rootPanel = new JPanel(new BorderLayout());
     {
       JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
       {
         JSplitPane splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
         {
           JTabbedPane tabbedPane = new JTabbedPane();
           {
             JPanel panel = new JPanel();
             BoxLayout layout = new BoxLayout(panel, BoxLayout.Y_AXIS);
             panel.setLayout(layout);
             {
               JPanel panel2 = new JPanel();
               {
                 inputTextField = new JTextField(8);
                 Font font = inputTextField.getFont();
                 font = font.deriveFont(font.getSize2D() * 3);
                 inputTextField.setFont(font);
                 panel2.add(inputTextField);
               }
               panel.add(panel2);
             }
             {
               JPanel panel2 = new JPanel();
               {
                 JButton button = new JButton("字");
                 button.setActionCommand("searchWithCharacter");
                 button.addActionListener(controller);
                 panel2.add(button);
               }
               {
                 JButton button = new JButton("詞");
                 button.setActionCommand("searchWithWord");
                 button.addActionListener(controller);
                 panel2.add(button);
               }
               {
                 JButton button = new JButton("音");
                 button.setActionCommand("searchWithReading");
                 button.addActionListener(controller);
                 panel2.add(button);
               }
               {
                 JButton button = new JButton("碼");
                 button.setActionCommand("searchWithCode");
                 button.addActionListener(controller);
                 panel2.add(button);
               }
               panel.add(panel2);
             }
             tabbedPane.addTab("輸入", panel);
           }
           {
             DefaultMutableTreeNode root = controller.getRadicalTree();
             JTree tree = new JTree(root);
             Font font = tree.getFont();
             font = font.deriveFont(font.getSize2D() * 1.5F);
             tree.setFont(font);
             tree.addTreeSelectionListener(controller);
             JScrollPane scrollPane =
                 new JScrollPane(
                     tree,
                     JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
             tabbedPane.addTab("部首", scrollPane);
           }
           {
             JPanel panel = new JPanel();
             BoxLayout layout = new BoxLayout(panel, BoxLayout.Y_AXIS);
             panel.setLayout(layout);
             {
               JPanel panel2 = new JPanel();
               panel2.add(new JLabel("從"));
               {
                 fromStrokesTextField = new JTextField("1", 2);
                 Font font = fromStrokesTextField.getFont();
                 font = font.deriveFont(font.getSize2D() * 2);
                 fromStrokesTextField.setFont(font);
                 fromStrokesTextField.setHorizontalAlignment(JTextField.RIGHT);
                 panel2.add(fromStrokesTextField);
               }
               panel2.add(new JLabel("到"));
               {
                 toStrokesTextField = new JTextField("10", 2);
                 Font font = toStrokesTextField.getFont();
                 font = font.deriveFont(font.getSize2D() * 2);
                 toStrokesTextField.setFont(font);
                 toStrokesTextField.setHorizontalAlignment(JTextField.RIGHT);
                 panel2.add(toStrokesTextField);
               }
               panel.add(panel2);
             }
             {
               JPanel panel2 = new JPanel();
               {
                 JButton button = new JButton("査");
                 button.setActionCommand("searchWithStrokes");
                 button.addActionListener(controller);
                 panel2.add(button);
               }
               panel.add(panel2);
             }
             tabbedPane.addTab("畫數", panel);
           }
           splitPane2.add(tabbedPane, JSplitPane.TOP);
         }
         {
           selectingList = new JList();
           Font font = selectingList.getFont();
           font = font.deriveFont(font.getSize2D() * 2);
           selectingList.setFont(font);
           selectingList.addMouseListener(controller);
           JScrollPane scrollPane =
               new JScrollPane(
                   selectingList,
                   JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                   JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
           scrollPane.setBorder(new TitledBorder("候補"));
           splitPane2.add(scrollPane, JSplitPane.BOTTOM);
         }
         splitPane.add(splitPane2, JSplitPane.LEFT);
       }
       {
         descriptionTextPane = new JTextPane();
         Font font = descriptionTextPane.getFont();
         font = font.deriveFont(font.getSize2D() * 1.5F);
         descriptionTextPane.setFont(font);
         descriptionTextPane.addMouseListener(controller);
         descriptionTextPane.addMouseMotionListener(controller);
         JScrollPane scrollPane =
             new JScrollPane(
                 descriptionTextPane,
                 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
         splitPane.add(scrollPane, JSplitPane.RIGHT);
       }
       rootPanel.add(splitPane, BorderLayout.CENTER);
     }
     {
       JPanel panel = new JPanel(new BorderLayout());
       {
         JLabel label = new JLabel("status");
         panel.add(label, BorderLayout.WEST);
       }
       rootPanel.add(panel, BorderLayout.SOUTH);
     }
     frame.setContentPane(rootPanel);
   }
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.pack();
   frame.setVisible(true);
 }