/* * AlignGui.java * * ... * ... * ... */ package aksis.alignment; import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; import javax.swing.*; import javax.swing.text.*; import java.awt.geom.*; import java.awt.font.*; import org.w3c.dom.*; import java.applet.AudioClip; import java.nio.charset.*; import java.util.regex.*; //import aksis.awt2.AwtUtil; // Oystein flyttet denne inn sammen med alt det andre. den var sÃ¥ensom der den satt helt for seg selv /** * * @author Oystein Reigem and Johan Utne Poppe */ class AlignGui extends JPanel { // hvor har j dette? //public static final int FIRST = 1; //public static final int NEXT = 2; //public static final int THIRD = 3; //public static final String[] whichAsWord = { "", "first", "second", "third" }; // basic layout is // FIRST_COL = 0 DO_COL = 1 SECOND_COL = 2 // +---------------+---------------+---------------+ // | | | | // FILE_ROW = 0 | open/save | options | open/save | // | buttons | | buttons | // +---------------+---------------+---------------+ // | | | | // ALIGNED_ROW = 1 | aligned | unalign | aligned | // | elements | button | elements | // +---------------+---------------+---------------+ // | | | | // WORK_ROW = 2 | elements | align & edit | elements | // | under work | buttons | under work | // +---------------+---------------+---------------+ // | | | | // CHANGE_ROW = 3 | more/less | | more/less | // | buttons | | buttons | // +---------------+---------------+---------------+ // | | | | // UNALIGNED_ROW = 4 | unaligned | batch align | unaligned | // | elements | button | elements | // +---------------+---------------+---------------+ // STATUS_ROW = 5 | status line | // +-----------------------------------------------+ // (layout is gridbag not so much because we have merged cells but because we need cells of varying sizes) // hvor har j dette? public static final int FIRST_COL = 0; public static final int DO_COL = 1; public static final int SECOND_COL = 2; public static final int THIRD_COL = 3; // not used //public static final int TEXT_COL_WEIGHT = 1; public static final int TEXT_COL_WEIGHT = 2; public static final int DO_COL_WEIGHT = 0; // hvis det st� 0 funker ikke MinimumSize // har jeg skrevet for lenge siden. // 2006-03-23 oppdaget jeg at 0 ordnet problem med bredden p�do-kolonnen. // med 1 ble do-kolonnen bredere enn ndvendig //public static final int DO_COL_WEIGHT = 1; public static final int FILE_ROW = 0; public static final int ALIGNED_ROW = 1; public static final int WORK_ROW = 2; public static final int CHANGE_ROW = 3; public static final int UNALIGNED_ROW = 4; public static final int STATUS_ROW = 5; public static final int FILE_ROW_WEIGHT = 0; //public static final int ALIGNED_ROW_WEIGHT = 5; public static final int ALIGNED_ROW_WEIGHT = 2; //public static final int WORK_ROW_WEIGHT = 3; public static final int WORK_ROW_WEIGHT = 0; public static final int CHANGE_ROW_WEIGHT = 0; //public static final int UNALIGNED_ROW_WEIGHT = 500; public static final int UNALIGNED_ROW_WEIGHT = 5; public static final int STATUS_ROW_WEIGHT = 0; public static final int MIN_DO_WIDTH = 200; //public static final int MIN_WORK_HEIGHT = 150; // ### blir ikke s�mye som 150? public static final int MIN_WORK_HEIGHT = 200; public static final int[] TEXT_COLS = { FIRST_COL, SECOND_COL, THIRD_COL }; // THIRD_COL not used //public static final int NUM_FILES = 2; // ... // private JButton openFileButton[]; //private JButton saveFileButton[]; private JButton saveAllFileButton; private JButton purgeButton; protected JPanel savePurgePanel; private JLabel filenameLabel[]; private JFileChooser chooser; // //options private JButton anchorFileButton; private JLabel anchorFilenameLabel; private JLabel settingsFilenameLabel; // 2006-09-21 // //DefaultListModel alignedModel[]; // package access JList alignedListBox[]; // package access JScrollPane alignedScrollPane[]; // package access // private JButton unalignButton; // //DefaultListModel toAlignModel[]; // package access JList toAlignListBox[]; // package access JScrollPane toAlignScrollPane[]; // package access // //protected JCheckBox skip11CheckBox; // burde v�t private, med get-metode? //protected JLabel skip11LimitLabel1; //protected JLabel skip11LimitLabel2; protected JLabel runLimitLabel1; protected JLabel runLimitLabel2; //protected JTextField skip11LimitTextField; protected JTextField runLimitTextField; //protected JPanel skip11Panel; //protected JPanel modePanel; protected JPanel runPanel; protected ModeRadioButtonPanel modeRadioButtonPanel; protected JPanel settingsPanel; protected JPanel logPanel; protected JPanel skipPanel; protected JPanel breakPanel; // 2006-08-15 protected JButton alignButton; // triks. "trykker" p�knappen programmatisk, fra model //private JButton editButton; // for text editing. and element editing????? private JButton settingsButton; // brings up dialog for various settings //private JButton logButton; // turns logging on or off private JButton startLoggingButton; private JButton stopLoggingButton; private JButton breakButton; // 2006-08-15 private JLabel logFilenameLabel; private JButton skipButton; // button for use when opening half-aligned files. to skip the already aligned beginning of the files //private JButton changeButton; // test //private JButton linkButton; // for detailed editing of correspondences //&&//private JButton correspButton; // for detailed editing of correspondences //private JLabel alignArrow; // //protected JPanel compareInfoPanel; protected CompareInfo compareInfoPanel; private JScrollPane compareInfoScrollPane; protected Graphics compareInfoGraphics; //private JTextArea anchorWordMatches; //private JTextArea matchInfoTextArea; protected JList matchInfoList; //private JScrollPane anchorWordMatchesScrollPane; private JScrollPane matchInfoScrollPane; //JTextArea anchorWordMatches; // component for display of the current anchor word matches // package access //JList anchorWordMatchesListBox; // component for display of the current anchor word matches // package access // private JButton moreButton[]; private JButton lessButton[]; //private JLabel moreLessArrow[]; // //DefaultListModel unalignedModel[]; // package access JList unalignedListBox[]; // package access JScrollPane unalignedScrollPane[]; // package access // //private JButton batchButton; // kan vi srge for at knappen f� en tekst som sier hvor mange linjer den vil ta??? private JButton suggestButton; //// burde v�t private, med set-metoder? skal jeg lage et statuslinjeobjekt? //protected JTextField counter; ////protected javax.swing.text.Document counterDoc; protected AlignStatusLine statusLine; // arrays of all the components lying in the same row. // for resizing of rows protected Component[] row2, row3, row5; protected double row2weighty, row5weighty; JMenuBar menuBar; // package access // mitt protected OpenAction[] openActions; /*protected SaveAction[] saveActions;*/ protected SaveAllAction saveAllAction; protected PurgeAction purgeAction; protected AnchorAction anchorAction; protected UnalignAction unalignAction; protected AlignAction alignAction; //protected EditAction // editAction; protected SettingsAction settingsAction; //protected LogAction // logAction; protected StartLoggingAction startLoggingAction; protected StopLoggingAction stopLoggingAction; protected SkipCorrespAction skipCorrespAction; protected BreakAction // 2006-08-15 breakAction; //protected ChangeAction // changeAction; //protected LinkAction // linkAction; //&&//protected CorrespAction //&&// correspAction; protected MoreAction[] moreActions; protected LessAction[] lessActions; //protected BatchAction // batchAction; protected SuggestAction suggestAction; protected HelpAction helpAction; // protected ToolTipAction toolTipAction; // // j AlignmentModel model; // package access GridBagLayout layout; // package access private AnchorDialog anchorDialog; private SettingsDialog settingsDialog; //############ skulle class modeRadioButtonPanel ogs�v�t her? //&&//// dialog for manually editing correspondences/links //&&//private CorrespDialog correspDialog; // mitt // // // Here's an example of a class that models the items in a list. // The class encapsulates the background color and text. // // ... -> AElement // String -> Object // forts. // // Here's an example of a class that implements the ListCellRenderer interface. // // Notice a few things about MyCellRenderer: // // It extends JLabel, another JFC Project Swing component. // JLabel is used to display text or images. // Extending JLabel is a convenient way to display selectable text or images. // // It sets opaque to true in the constructor. // This instructs the paint system to use the background of that particular component. // // It implements getListCellRendererComponent, // the only method in the ListCellRenderer interface. // This method sets the attributes of the class // and then returns a reference to the class. // // The setText method uses the string value stored // in the AElement object to set the JLabel text, // and the setBackground method uses the color value stored // in the AElement object to set the background color of the JLabel. // // If the list item is selected, that is the iss parameter // of getListCellRendererComponent is true, // MyCellRenderer uses the setBorder method to set // a two-pixel blue border around the list item. // The border around the item signals that the item is selected // // ... -> AElement // etc // // The customization possibilities don't end here. // By having the MyCellRenderer class extend a component other than JLabel, // you can create a wide variety of visually engaging lists. //class MyCellRenderer extends JLabel implements ListCellRenderer { // === class MyCellRenderer extends JTextArea implements ListCellRenderer { // === //class MyCellRenderer extends JTextPane implements ListCellRenderer { //class MyCellRenderer extends JTextField implements ListCellRenderer { public MyCellRenderer () { // Don't paint behind the component setOpaque(true); } // Set the attributes of the // class and return a reference public Component getListCellRendererComponent( JList list, Object value, // value to display int index, // cell index boolean iss, // is selected boolean chf) // cell has focus? { // Set the text and // background color for rendering ////System.out.println("value har klasse " + value.getClass().getName()); //AElement test = (AElement)value; // java.lang.ClassCastException. men prver det p�nytt. hmm. problemer i aligned, men ikke i toAlign! //AElement temp = new AElement(value); // men f� det til p�denne m�en. ok? ////System.out.println(temp); //Object test = value; //setText(((AElement)(Object)value).getValue().toString()); //setText(test.element.toString()); String text = ((AElement)(value)).toString(); //### flgende test gir litt merkelig resultat. // hyden er nemlig gjerne basert p�et annet innhold enn du ser, // fordi denne metoden stadig trigges til �regne p�nytt //text = "abcde".substring(0, (int)(5 * Math.random() + 1)); // #######test 2006-09-19 //text = "abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc x"; // #######test 2006-09-19 /* ###didn't help. LineBreakMeasurer deler alle mulige steder: " ' . // 2006-9-15 // ###replace all " by ' because of a bug in LineBreakMeasurer //System.out.println("3"); Pattern pattern = Pattern.compile("\""); Matcher matcher = pattern.matcher(text); //text = matcher.replaceAll("'"); text = matcher.replaceAll("'"); // end 2006-9-15 */ //String escapedText = ""; // === escape. ###nei, dette skjnner visst ikke JLabel. kodene og ]]> viser //String escapedText = "" + Utils.stringToHTMLString(text) + ""; // if extends JLabel setText(text); // if extends JTextArea //setText(escapedText); // if extends JLabel //setBackground(((AElement)value).getColor()); //setBackground(test.getColor()); setBackground(((AElement)(value)).getColor()); // Wrap-greier funker ikke. eneste virkning at horiz scroll forsvant. // aha. er det wrappet, men s�ser vi bare frste linjen? // prvde for sikkerhets skyld alle kombinasjoner av de to. // ### hjalp ikke �flytte dette foran setText etc. //setLineWrap(false); ### hjalp ikke �riste i det setLineWrap(true); // if extends JTextArea setWrapStyleWord(true); // if extends JTextArea //setWrapStyleWord(false); //... // //System.out.println("width=" + getScrollableTracksViewportWidth()); printer false hvis wrapping p�l�t og true ellers // Set a border if the // list item is selected if (iss) { setBorder(BorderFactory.createLineBorder(Color.blue, 1)); // 1 = width of border in pixels } else { setBorder(BorderFactory.createLineBorder(list.getBackground(), 1)); // 1 = width of border in pixels } //int rowHeight = (int)getPreferredSize().getHeight(); //if (list.getHeight() != rowHeight) table.setHeight(rowHeight); //System.out.println("(int)getPreferredSize().getHeight() = " + (int)getPreferredSize().getHeight()); //System.out.println("getHeight() = " + getHeight()); ### 0 //System.out.println("list.getFixedCellWidth() = " + list.getFixedCellWidth()); // ### -1 //System.out.println("getFixedCellHeight() = " + getFixedCellHeight()); //System.out.println("list.getWidth()=" + list.getWidth()); //System.out.println("getWidth()=" + getWidth()); ### 0 //list.revalidate(); // ### hjelper ikke. f� ikke resizet cellene. men dette skulle vel ikke st�t akkurat her heller //if (false) { // ###for �kjre uten word wrap //System.out.println("fr getGraphics()"); //Graphics2D gg = (Graphics2D)list.getGraphics(); // ###dette er vel feil for JTextArea i hvert fall! m�vel f�graphics fra cellen, ikke listen // use font from list for cell // 2006-09-19 setFont(list.getFont()); // 2006-09-19 //System.out.println("etter getGraphics()"); Graphics2D gg = (Graphics2D)getGraphics(); // 2006-09-19 // for extends JLabel. and JTextArea??? if (gg != null) { // for extends JLabel. and JTextArea??? //System.out.println("this.getWidth()=" + this.getWidth()); // 0 //System.out.println("list.getWidth()=" + list.getWidth()); setSize(new Dimension(list.getWidth() - 30, 0)); // 2006-09-19 //System.out.println("gg != null"); //Font font = gg.getFont(); /* 2006-09-15. dette er vel foreldet for en stund siden FontRenderContext frc = gg.getFontRenderContext(); Rectangle2D textBounds = font.getStringBounds(text, frc); // (original text, not escaped) int textWidth = (int)textBounds.getWidth(); */ // 2006-03-24. there seems to be a bug in font.getStringBounds(text, frc).getWidth() // if the text contains e.g the — character the height is returned as 3 instead of 15 //int textHeight = (int)textBounds.getHeight(); //Rectangle2D textBounds2 = font.getStringBounds("XXX", frc); <<<=== //int textHeight = (int)textBounds2.getHeight(); <<<=== // now that was clunky... //int numLines = (int)(textWidth / list.getWidth()) + 1; // ### altfor primitivt. hvordan kan vi finne textrect <<<=== // getWidth() returnerer forskjellige verdier!!!!! // 2006-09-15. b�e riktig verdi og lavere enn riktig verdi. // det er vel noe med at det beregnes ut fra innholdet. // men innholdet er jo det som vi nsker �.... // ###og verdien er forresten aldri riktig, for det er ikke trukket fra for scrollbar!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // ###ah! det hjelper �sette vertical scrollbar policy always! da blir det rett verdi, og samme verdi alltid //int listWidth = (int)list.getWidth(); //System.out.println("listWidth = " + listWidth); //int viewportWidth = (int)list.getPreferredScrollableViewportSize().getWidth(); //System.out.println("gg != null"); //setRows(numLines); // ### 30: hack for �trekke fra plass til vert scrollbar. // +1: ser at det blir 1 pixel luft mellom linjene i tillegg til det getHeight() sier. // +5: for �f�nok luft nede. blir n�4 oppe og 4 nede //setPreferredSize(new Dimension(listWidth - 30, ((textHeight + 1) * numLines) + 5)); // ### listWidth may change from line to line. should have used a fixed value //int h = ((textHeight + 1) * numLines) + 5; <<<=== //int h = Utils.wrappedTextHeight(text, font, list.getWidth()); // 2006-08-15 <<<==============PR� DENNE //int h = Utils.wrappedTextHeight(" " + text, font, list.getWidth() - 6); // 2006-09-15 ###forbannet triks. JLabel, som er den som gjr linjebrettingen, rykker visst inn frste linje � pixel. simulerer dette med en space foran teksten. ###men dette var ikke nok. prver ogs�med mindre bredde //int h = Utils.wrappedTextHeight(" " + text, gg, list.getWidth()); // 2006-09-15 // 2006-09-18. prvde JTextArea igjen. wrapper ok. // men cellen blir forferdelig hy hvis ikke noe setter hyden // men for lav hvis jeg bruker Utils.wrappedTextHeight(). // og _formodentlig_ med samme bug i brekkingen ("'.) //int h = Utils.wrappedTextHeight(text, gg, list.getWidth()); // 2006-09-15 // for extends JLabel //setPreferredSize(new Dimension(0, h)); // width 0 seems to disturb width less // for extends JLabel //setVerticalAlignment(SwingConstants.TOP); // if extends JLabel // ### 30 funker ikke. ingen forskjell om ker til 100 eller 200. // ### og ingen forskjell om setMaximumSize i tillegg //setMaximumSize(new Dimension(listWidth - 30, ((textHeight + 1) * numLines) + 5)); // ### hjelper ikke //setSize(new Dimension(list.getWidth() - 30, textHeight * numLines)); // ### g� ikke bedre med setSize enn setPreferredSize //setPreferredSize(new Dimension(getWidth() - 30, textHeight * numLines)); // ### getWidth() er 0 /* if (index < 250) { System.out.println("----------------"); System.out.println("index = " + index); //System.out.println("font = " + font); System.out.println("text = " + text); //System.out.println("textBounds = " + textBounds); System.out.println("textWidth = " + textWidth + ", textHeight = " + textHeight); System.out.println("numLines = " + numLines); System.out.println("setPreferredSize 0, " + h); } */ } // for extends JLabel. and JTextArea??? //} //layout.layoutContainer(this); // ### hjelper ikke. f� ikke resizet cellene. kommenterer den ut igjen i tilfelle den tar ressurser return this; } } // mitt // hvor skal denne? /** Returns an ImageIcon, or null if the path was invalid. */ protected static ImageIcon createImageIcon(String path, String description) { java.net.URL imgURL = AlignGui.class.getResource(path); if (imgURL != null) { return new ImageIcon(imgURL, description); } else { //System.err.println("Couldn't find file: " + path); return null; } } // hvor skal denne? private int getWhich(String command) throws MyException { for (int t=0; t if (ToolTipManager.sharedInstance().isEnabled()) { // enable tool tips for the entire application ToolTipManager.sharedInstance().setEnabled(false); } else { // disable tool tips for the entire application ToolTipManager.sharedInstance().setEnabled(true); } } } public int getMode() { int mnemonic = AlignGui.this.modeRadioButtonPanel.rbg.getSelection().getMnemonic(); if (mnemonic == KeyEvent.VK_O) { return Alignment.MODE_ONE; } else if (mnemonic == KeyEvent.VK_S) { return Alignment.MODE_SKIP11; } else if (mnemonic == KeyEvent.VK_A) { return Alignment.MODE_AUTO; } else { // ##### program error #### return Alignment.MODE_ONE; } } public void setAnchorFilenameLabel(String fileName) { anchorFilenameLabel.setText(fileName); } // 2006-09-21 public void setSettingsFilenameLabel(String fileName) { settingsFilenameLabel.setText(fileName); } // end 2006-09-21 public void setLogFilenameLabel(String fileName) { logFilenameLabel.setText(fileName); } AlignGui(AlignmentModel model) { // set to Windows look & feel String plafClassName = // de som ser normale ut er kanskje ikke tilgjengelige/til stede, alts�at vi f� default isteden "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; // denne er annerledes //"com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; // ser "normal" ut //"javax.swing.plaf.metal.MetalLookAndFeel"; // ser "normal" ut //"com.sun.java.swing.plaf.motif.MotifLookAndFeel"; // denne er annerledes //UIManager.getCrossPlatformLookAndFeelClassName(); // ser "normal" ut //"it.unitn.ing.swing.plaf.macos.MacOSLookAndFeel"; // ser "normal" ut //"com.incors.plaf.kunststoff.KunststoffLookAndFeel"; // ser "normal" ut try { UIManager.setLookAndFeel(plafClassName); } catch(Exception ex) { System.out.println(ex); } SwingUtilities.updateComponentTreeUI(this); // ... this.model = model; String key; // 2006-08-15 // make the important objects // create actions shared by buttons, menus, etc. // open file actions OpenAction[] openActions = new OpenAction[Alignment.NUM_FILES]; for (int t=0; t"); filenameLabel[t] = new JLabel(""); //alignedModel[t] = new DefaultListModel(); ////System.out.println("--------------"); ////this.model.aligned.hello(); ////System.out.println("--------------"); ////System.out.println(this.model.getClass().getName()); ////System.out.println(this.model.aligned.getClass().getName()); ////System.out.println(this.model.aligned.elements.getClass().getName()); ////System.out.println(this.model.aligned.elements[t].getClass().getName()); alignedListBox[t] = new JList(this.model.aligned.elements[t]); // mitt alignedListBox[t].setName("A" + t); alignedListBox[t].setCellRenderer(new MyCellRenderer()); // ### MyCellRenderer burde vel hete ettellerannetelementsCellRenderer //alignedListBox[t].setFont(new Font("Arial Unicode MS", Font.PLAIN, 10)); // 2006-09-15 //toAlignModel[t] = new DefaultListModel(); toAlignListBox[t] = new JList(this.model.toAlign.elements[t]); // mitt toAlignListBox[t].setName("T" + t); // mouse event handler needs a name, to be able to find out which list box was clicked toAlignListBox[t].setCellRenderer(new MyCellRenderer()); //toAlignListBox[t].setFont(new Font("Arial Unicode MS", Font.PLAIN, 10)); // 2006-09-15 lessButton[t] = new JButton(lessActions[t]); moreButton[t] = new JButton(moreActions[t]); //moreLessArrow[t] = new JLabel(""); //unalignedModel[t] = new DefaultListModel(); unalignedListBox[t] = new JList(this.model.unaligned.elements[t]); // mitt unalignedListBox[t].setName("U" + t); // n� forsvant horiz scroll? n� jeg prvde JTextArea? og tekst kappet ved ordgrense dvs ser flere ord hvis resizer hor //unalignedListBox[t].setFixedCellWidth(10); // for JTextArea. gjorde ingen forskjell //unalignedListBox[t].setPrototypeCellValue("xxxxxxxxxxxxxxx"); // for JTextArea. gjorde ingen forskjell? //System.out.print("width:"); //System.out.println(unalignedListBox[t].getFixedCellWidth()); unalignedListBox[t].setCellRenderer(new MyCellRenderer()); //System.out.print("width:"); //System.out.println(unalignedListBox[t].getFixedCellWidth()); //unalignedListBox[t].setFont(new Font("Arial Unicode MS", Font.PLAIN, 10)); // 2006-09-15 } // handler for mouse events in toAlign // kan vi ha denne som en action? // er det mulig �gjre dette uten mus? MouseListener toAlignMouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { //Toolkit.getDefaultToolkit().beep(); // 2006-09-25 Object[] options = { "Yes", "No" }; // button texts int n = JOptionPane.showOptionDialog( null, "Do you want to change the suggested alignment(s)", "Change alignment(s)", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1] // the choice that is initially selected ); if(n == 0) { // YES // end 2006-09-25 // gjentas mange ganger AlignGui.this.statusLine.clear(); /* String type = ""; if (e.getClickCount() == 2) { type = "Double"; } else { type = "Single"; } */ //System.out.println("toAlignMouseListener"); int tClicked = Integer.parseInt(e.getComponent().getName().substring(1, 2)); //System.out.println("Clicked in text " + (tClicked+1)); int indexClicked = ((JList)(e.getComponent())).locationToIndex(e.getPoint()); //System.out.println("Clicked on JList item " + indexClicked); int elementNumberClicked = ((AElement)(AlignGui.this.model.toAlign.elements[tClicked].get(0))).elementNumber + indexClicked; //System.out.println("Clicked on element " + elementNumberClicked); int alignmentNumberClicked = ((AElement)(AlignGui.this.model.toAlign.elements[tClicked].get(indexClicked))).alignmentNumber; //System.out.println("Clicked on alignment " + alignmentNumberClicked); //// forelpig: linker til verste pending //AlignGui.this.model.link(AlignGui.this, tClicked, indexClicked, elementNumberClicked); AlignGui.this.model.link(AlignGui.this, tClicked, indexClicked, elementNumberClicked, -2); // being told to link to alignment number -2 is a signal to link to next available pending alignment // } // 2006-09-25 } }; for (int t=0; t 0) { //System.out.println("elementNumbers.size() > 0"); // find smallest index of aligned element in other text int smallestIndex = Integer.MAX_VALUE; int highestIndex = Integer.MIN_VALUE; //System.out.println("smallestIndex = " + smallestIndex); //System.out.println("highestIndex = " + highestIndex); Iterator eIt = alignment.elementNumbers[t].iterator(); while (eIt.hasNext()) { int elementNumber = ((Integer)(eIt.next())).intValue(); if (elementNumber < smallestIndex) { smallestIndex = elementNumber; } if (elementNumber > highestIndex) { highestIndex = elementNumber; } //System.out.println("smallestIndex = " + smallestIndex); //System.out.println("highestIndex = " + highestIndex); } // first scroll the last element of the alignment into view... // ###### better alternative might be to scroll very last element // of the list box into view. this will - in the next step - // make the first element appear at the very top of the list box, // if possible, securing a better *visual* alignment alignedListBox[t].ensureIndexIsVisible(highestIndex); // ...then the first element. // now all the elements should be visible, // unless the elements are long and many in number. // in the worst case at least the first one should be visible now alignedListBox[t].ensureIndexIsVisible(smallestIndex); alignedListBox[t].setSelectedIndex(smallestIndex); } else { //System.out.println("!(elementNumbers.size() > 0)"); // ### forelpig programmering. // ### n-0-alignment. m�lete opp en etterflger. i.g.n.m Toolkit.getDefaultToolkit().beep(); //System.out.println("BEEEEEEEEEEEEEEEEP mouseClicked"); //System.out.println("Some programming missing here?"); // kommentert ut 2006-10-04, uten at jeg har sett p�saken } //} } } else { // "U" // user clicked in unaligned int elementNumberClicked = ((AElement)(AlignGui.this.model.unaligned.elements[tClicked].get(0))).elementNumber + indexClicked; //System.out.println("Clicked on element " + elementNumberClicked); int numThis = unalignedListBox[tClicked].getModel().getSize(); int numOther = -1; int otherIndex = -1; for (int t=0; tInformation about how well the elements under manual consideration match,
nwith details about anchor word matches, Dice, etc.
Note: The information is based solely on the elements under consideration.
There is no look-ahead.
Note: The elements under consideration may belong to more than one alignment
(they have more than one colour), but this box doesn't know anything about that"); matchInfoList.setToolTipText("Information about how well the elements under manual consideration match,
nwith details about anchor word matches, Dice, etc.
Note: The information is based solely on the elements under consideration.
There is no look-ahead.
Note: The elements under consideration may belong to more than one alignment
(they have more than one colour), but this box doesn't know anything about that"); for (int t=0; tContains the element(s) under manual consideration for alignment, from text " + (t+1) + ".
Click elements to include them in alignments"); ////toAlignListBox[t].setVisible(false); moreButton[t].setToolTipText("Move one unaligned element up in " + (t+1) + ". file"); lessButton[t].setToolTipText("Drop one element under consideration in " + (t+1) + ". file"); unalignedListBox[t].setToolTipText("Contains the not yet aligned elements of text " + (t+1)); } //////////// // layout // //////////// layout = new GridBagLayout(); setLayout(layout); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(3,3,3,3); c.anchor = GridBagConstraints.NORTH; AwtUtil util = new AwtUtil(this, layout, c); //// colours // set background colour /* Girlie Edition colours //Color[] bgColors = { Color.pink, Color.yellow, Color.white, Color.cyan }; // ### disse kan ikke bli .brighter() Color[] bgColors = { Color.pink, Color.yellow, Color.cyan }; // ### disse kan ikke bli .brighter() Random rand = new Random(); int r = rand.nextInt(100000) % bgColors.length; this.setBackground(bgColors[r]); //Color buttonColor = this.getBackground().darker(); int r2; do { r2 = rand.nextInt(100000) % bgColors.length; } while (r2 == r); Color buttonColor = bgColors[r2]; int r3; do { r3 = rand.nextInt(100000) % bgColors.length; } while ((r3 == r) || (r3 == r2)); Color buttonTextColor = bgColors[r3]; */ //// Marl�'s colours //Color bgColor = new Color(0xF5DEB3); // #F5DEB3 this.setBackground(bgColor); // ### kommenterte ut denne for �prve bakgrunnsbilde isteden. fikk det til. se Alignment.java og neste linje //this.setOpaque(false); // trenger denne for bakgrunnsbilde //Color buttonColor = new Color(0x94BA45); // #94BA45 //Color buttonTextColor = new Color(0x006400); // #006400 // tenkte jeg skulle ha en felles farge p�det som har med to-align �gjre, siden det ikke st� p�linje. // men det skjedde bisarre ting n� jeg gjorde dette. var det noe som skinte igjennom? (har lav alpha.) // er det noe feil i grensesnittet? prvde med to-align + dens scroll usynlig, men s�ikke noe da. /*Color paleGreen = new Color(0, 255, 0, 5); for (int t=0; t