public void searchWithStrokes() throws SQLException { int fromStrokes = hydc3View.getFromStrokes(); int toStrokes = hydc3View.getToStrokes(); if (fromStrokes <= toStrokes) { String[] sCharacters = hydc3Model.searchWithStrokes(fromStrokes, toStrokes); hydc3View.setSelectingList(sCharacters); } }
public void searchWithCode() throws SQLException { String sCode = hydc3View.getInputText(); int code = 0; if (sCode.matches("(0[Xx]|U\\+)[0-9A-Fa-f]+")) { code = Integer.parseInt(sCode.substring(2), 16); } else if (sCode.matches("[0-9]+")) { code = Integer.parseInt(sCode); } else if (sCode.matches("[0-9A-Fa-f]+")) { code = Integer.parseInt(sCode, 16); } String[] sCharacters = hydc3Model.searchWithCode(code); hydc3View.setSelectingList(sCharacters); }
public void searchWithWord() throws SQLException { String[] sWords = hydc3Model.searchWithWord(hydc3View.getInputText()); hydc3View.setSelectingList(sWords); }
public void searchWithCharacter() throws SQLException { String[] sCharacters = hydc3Model.searchWithCharacter(hydc3View.getInputText()); hydc3View.setSelectingList(sCharacters); }
public DefaultMutableTreeNode getRadicalTree() throws SQLException { return hydc3Model.getRadicalTree(); }
@Override public void mouseClicked(MouseEvent event) { if (event.getClickCount() == 2 && event.getSource() instanceof JList) { Cursor cursor = hydc3View.getCursor(); hydc3View.setCursor(new Cursor(Cursor.WAIT_CURSOR)); String s = hydc3View.getSelected(); try { hydc3View.clearDescriptionTextPane(); if (s.matches(".[0-9]+ .+")) { int index = Integer.parseInt(s.split(" ")[0].substring(1)); s = s.substring(0, 1); hydc3Model.getDescriptionsByCharacterAndIndex(s, index); } else if (s.length() == 1) { hydc3Model.getDescriptionsByCharacter(s); } else { hydc3Model.getDescriptionsByWord(s); } hydc3View.setDescriptionTextPaneTop(); } catch (Exception e) { e.printStackTrace(); } hydc3View.setCursor(cursor); } else if (event.getSource() instanceof JTextPane) { JTextPane textPane = (JTextPane) event.getSource(); Point point = new Point(event.getX(), event.getY()); int position = textPane.viewToModel(point); DefaultStyledDocument document = (DefaultStyledDocument) textPane.getDocument(); Element element = document.getCharacterElement(position); AttributeSet attributeSet = element.getAttributes(); String sLink = (String) attributeSet.getAttribute("link"); if (sLink != null) { Cursor cursor = hydc3View.getCursor(); hydc3View.setCursor(new Cursor(Cursor.WAIT_CURSOR)); try { if (sLink.matches(".")) { hydc3View.clearDescriptionTextPane(); hydc3Model.getDescriptionsByCharacter(sLink); hydc3View.setDescriptionTextPaneTop(); } else if (sLink.matches(".[0-9]+")) { int index = Integer.parseInt(sLink.substring(1)); hydc3View.clearDescriptionTextPane(); hydc3Model.getDescriptionsByCharacterAndIndex(sLink.substring(0, 1), index); hydc3View.setDescriptionTextPaneTop(); } else { HashMap<String, Integer> wordPositionMap = hydc3View.getWordPositionMap(); Integer iPosition = wordPositionMap.get(sLink); if (iPosition != null) { hydc3View.setDescriptionTextPaneCaretPosition(iPosition); } else { hydc3View.clearDescriptionTextPane(); hydc3Model.getDescriptionsByWord(sLink); hydc3View.setDescriptionTextPaneTop(); } } } catch (Exception e) { e.printStackTrace(); } hydc3View.setCursor(cursor); } } }