From: <hee...@us...> - 2009-05-06 13:15:11
|
Revision: 1741 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1741&view=rev Author: heeroyuy Date: 2009-05-06 13:15:10 +0000 (Wed, 06 May 2009) Log Message: ----------- -removed EllipseTest -removed checkstyle warnings -update suggest list only when item has changed -update graphical panel when suggest list item is updated Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java trunk/src/dl-learner/org/dllearner/tools/protege/IndividualPoint.java trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/tools/protege/EllipseTest.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2009-05-06 10:53:22 UTC (rev 1740) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2009-05-06 13:15:10 UTC (rev 1741) @@ -74,15 +74,10 @@ /** * This is the constructor for the action handler. - * - * @param a - * ActionHandler * @param m * DLLearnerModel * @param view * DLlearner tab - * @param i - * id if it is a subclass or an equivalent class * */ public ActionHandler(DLLearnerModel m, DLLearnerView view) { @@ -102,7 +97,8 @@ if (z.getActionCommand().equals("suggest equivalent class expression") || z.getActionCommand().equals("suggest super class expression")) { model.setKnowledgeSource(); - //model.setReasoner(); + view.getSuggestClassPanel().getSuggestModel().clear(); + view.getSuggestClassPanel().repaint(); model.setLearningProblem(); model.setLearningAlgorithm(); view.getRunButton().setEnabled(false); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2009-05-06 10:53:22 UTC (rev 1740) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2009-05-06 13:15:10 UTC (rev 1741) @@ -162,8 +162,6 @@ * * @param editorKit * Editor Kit to get the currently loaded Ontology - * @param id - * String if it learns a subclass or a superclass. * @param view * current view of the DL-Learner tab */ @@ -181,6 +179,10 @@ sources = new HashSet<KnowledgeSource>(); } + /** + * Sets the ID if an equivalent or a superclass must be suggested. + * @param d ID if it is an equivalent or a superclass + */ public void setID(String d) { this.id = d; } @@ -495,13 +497,30 @@ return individual; } + /** + * This method returns if the ID is an equivalent or a superclass. + * @return id if it is an equivalent or superclass + */ public String getID() { return id; } + /** + * Returns boolean if reasoner is allready set. + * @return isReasonerSet + */ public boolean isReasonerSet() { return isReasonerSet; } + + /** + * This method returns the currently selected class description as an evaluated description. + * @param index which class descriptions is selected + * @return selected class description + */ + public EvaluatedDescription getCurrentlySelectedClassDescription(int index) { + return evalDescriptions.get(index); + } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2009-05-06 10:53:22 UTC (rev 1740) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2009-05-06 13:15:10 UTC (rev 1741) @@ -127,13 +127,12 @@ * editor. * * @param editor OWLEditorKit - * @param label String */ public DLLearnerView(OWLEditorKit editor) { editorKit = editor; labels = ""; model = new DLLearnerModel(editorKit, this); - sugPanel = new SuggestClassPanel(); + sugPanel = new SuggestClassPanel(model, this); learnerPanel = new JPanel(); learnerPanel.setLayout(new BorderLayout()); learnerScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); @@ -191,6 +190,7 @@ /** * This Method renders the view of the plugin. + * @param label label if it is an equivalent or superclass */ public void makeView(String label) { run.setEnabled(false); @@ -282,6 +282,8 @@ sugPanel.setVisible(true); learnerScroll.setViewportView(learner); this.renderErrorMessage(""); + this.getSuggestClassPanel().getSuggestModel().clear(); + this.getSuggestClassPanel().repaint(); } @@ -303,6 +305,10 @@ } } + /** + * This method enables the GraphicalCoveragePanel after a class expression is + * selected from the list. + */ public void setGraphicalPanel() { GridBagConstraints c = new GridBagConstraints(); learner.remove(posPanel); @@ -380,6 +386,9 @@ return model.getNewOWLDescription(); } + /** + * This method unsets all results after closing the plugin. + */ public void dispose() { this.unsetEverything(); sugPanel.getSuggestList().removeAll(); @@ -485,14 +494,26 @@ setHintMessage(message); } + /** + * This method returns the view of the plugin. + * @return Plugin view + */ public JComponent getLearnerView() { return learnerScroll; } + /** + * This method returns the model of the DL-Learner plugin. + * @return model of the plugin + */ public DLLearnerModel getDLLearnerModel() { return model; } + /** + * This method returns the thread for initializing the reasoner and reading the ontology. + * @return thread that initializes the reasoner + */ public ReadingOntologyThread getReadingOntologyThread() { return readThread; } Deleted: trunk/src/dl-learner/org/dllearner/tools/protege/EllipseTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/EllipseTest.java 2009-05-06 10:53:22 UTC (rev 1740) +++ trunk/src/dl-learner/org/dllearner/tools/protege/EllipseTest.java 2009-05-06 13:15:10 UTC (rev 1741) @@ -1,58 +0,0 @@ -package org.dllearner.tools.protege; - -import java.awt.Color; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.geom.Ellipse2D; -import java.awt.geom.Point2D; -import java.util.Random; - -import javax.swing.JDialog; -import javax.swing.JPanel; - -public class EllipseTest extends JPanel { - - private static final long serialVersionUID = -5676466024192284648L; - private final Ellipse2D te; - private final Random random; - - public EllipseTest() { - te = new Ellipse2D.Double(0, 0, 150, 150); - this.setSize(500, 500); - random = new Random(); - JDialog dialog = new JDialog(); - dialog.add(this); - dialog.setSize(600, 600); - dialog.setVisible(true); - } - - @Override - protected void paintComponent(Graphics g) { - Graphics2D g2D; - g2D = (Graphics2D) g; - g2D.setColor(Color.YELLOW); - g2D.fill(te); - g2D.setColor(Color.RED); - double x = random.nextInt(500); - double y = random.nextInt(500); - int i = 0; - while (i < 1000) { - Point2D point = new Point2D.Double(x, y); - if (te.contains(point)) { - Ellipse2D circlePoint = new Ellipse2D.Double(x - 1, y - 1, 3, 3); - g2D.draw(circlePoint); - // g2D.drawString("*", ((int)x), ((int) y)); - x = random.nextInt(500); - y = random.nextInt(500); - i++; - } else { - x = random.nextInt(500); - y = random.nextInt(500); - } - } - } - - public static void main(String[] args) { - new EllipseTest(); - } -} Modified: trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2009-05-06 10:53:22 UTC (rev 1740) +++ trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2009-05-06 13:15:10 UTC (rev 1741) @@ -53,6 +53,7 @@ private static final int PLUS_SIZE = 5; private static final int SUBSTRING_SIZE = 25; private static final int SPACE_SIZE = 7; + private static final int MAX_RANDOM_NUMBER = 300; private static final String EQUI_STRING = "equivalent class"; private final String id; private int shiftXAxis; @@ -120,7 +121,7 @@ posNotCovIndVector = new Vector<IndividualPoint>(); additionalIndividuals = new Vector<IndividualPoint>(); points = new Vector<IndividualPoint>(); - this.computeGraphics(0, 0); + this.computeGraphics(); handler = new GraphicalCoveragePanelHandler(this, desc, model); if(shiftXAxis == 0) { oldConcept = new Ellipse2D.Double(ELLIPSE_X_AXIS + (2 * adjustment)+3, @@ -139,7 +140,7 @@ + adjustment, ELLIPSE_Y_AXIS, WIDTH + distortionOld, HEIGHT + distortionOld); } - this.computeIndividualPoints(300); + this.computeIndividualPoints(); this.addMouseMotionListener(handler); this.addMouseListener(handler); } @@ -376,7 +377,7 @@ } } - private void computeGraphics(int w, int h) { + private void computeGraphics() { if (eval != null) { this.setVisible(true); panel.repaint(); @@ -385,7 +386,7 @@ distortionOld = 0; adjustment = 0; Ellipse2D old = new Ellipse2D.Double(ELLIPSE_X_AXIS, ELLIPSE_Y_AXIS, - WIDTH + w, HEIGHT + h); + WIDTH, HEIGHT); x1 = (int) old.getCenterX() - PLUS_SIZE; x2 = (int) old.getCenterX() + PLUS_SIZE; y1 = (int) old.getCenterY() - PLUS_SIZE; @@ -393,19 +394,19 @@ centerX = (int) old.getCenterX(); centerY = (int) old.getCenterY(); double coverage = ((EvaluatedDescriptionClass) eval).getCoverage(); - shiftXAxis = (int) Math.round((WIDTH + w) * (1 - coverage)); + shiftXAxis = (int) Math.round((WIDTH) * (1 - coverage)); if (additionalIndividualSize != 0 && ((EvaluatedDescriptionClass) eval).getCoverage() == 1.0 && ((EvaluatedDescriptionClass) eval).getAddition() < 1.0) { - distortionOld = (int) Math.round((WIDTH + w) * 0.3); + distortionOld = (int) Math.round((WIDTH) * 0.3); Ellipse2D newer = new Ellipse2D.Double(ELLIPSE_X_AXIS + shiftXAxis, - ELLIPSE_Y_AXIS, (WIDTH + w), HEIGHT + h); + ELLIPSE_Y_AXIS, (WIDTH), HEIGHT); adjustment = (int) Math.round(newer.getCenterY() / 4); } - this.renderPlus(w); + this.renderPlus(); } } - private void renderPlus(int w) { + private void renderPlus() { if (eval != null) { coveredIndividualSize = ((EvaluatedDescriptionClass) eval) .getCoveredInstances().size(); @@ -418,17 +419,17 @@ shiftNewConceptX = 0; shiftCovered = 0; if (coveredIndividualSize == 0) { - shiftNewConcept = (int) Math.round(((WIDTH + w) / 2.0) * newConcepts); + shiftNewConcept = (int) Math.round(((WIDTH) / 2.0) * newConcepts); } else if (additionalIndividualSize != coveredIndividualSize) { - shiftNewConcept = (int) Math.round(((WIDTH + w) / 2.0) + shiftNewConcept = (int) Math.round(((WIDTH) / 2.0) * (1.0 + (1.0 - oldConcepts))); - shiftOldConcept = (int) Math.round(((WIDTH + w) / 2.0) * oldConcepts); - shiftCovered = (int) Math.round(((WIDTH + w) / 2.0) + shiftOldConcept = (int) Math.round(((WIDTH) / 2.0) * oldConcepts); + shiftCovered = (int) Math.round(((WIDTH) / 2.0) * (1 - oldConcepts)); } if (((EvaluatedDescriptionClass) eval).getAddition() != 1.0 && ((EvaluatedDescriptionClass) eval) .getCoverage() == 1.0) { - shiftCovered = (int) Math.round(((WIDTH + w) / 2.0) * 0.625); + shiftCovered = (int) Math.round(((WIDTH) / 2.0) * 0.625); shiftNewConceptX = shiftCovered; shiftNewConcept = 2 * shiftNewConceptX; } @@ -478,13 +479,13 @@ } } - private void computeIndividualPoints(int n) { + private void computeIndividualPoints() { if (eval != null) { Set<Individual> posInd = ((EvaluatedDescriptionClass) eval) .getCoveredInstances(); int i = 0; - double x = random.nextInt(n); - double y = random.nextInt(n); + double x = random.nextInt(MAX_RANDOM_NUMBER); + double y = random.nextInt(MAX_RANDOM_NUMBER); boolean flag = true; for (Individual ind : posInd) { flag = true; @@ -507,12 +508,12 @@ i++; flag = false; - x = random.nextInt(n); - y = random.nextInt(n); + x = random.nextInt(MAX_RANDOM_NUMBER); + y = random.nextInt(MAX_RANDOM_NUMBER); break; } else { - x = random.nextInt(n); - y = random.nextInt(n); + x = random.nextInt(MAX_RANDOM_NUMBER); + y = random.nextInt(MAX_RANDOM_NUMBER); } } @@ -522,8 +523,8 @@ Set<Individual> posNotCovInd = ((EvaluatedDescriptionClass) eval) .getAdditionalInstances(); int j = 0; - x = random.nextInt(n); - y = random.nextInt(n); + x = random.nextInt(MAX_RANDOM_NUMBER); + y = random.nextInt(MAX_RANDOM_NUMBER); for (Individual ind : posNotCovInd) { flag = true; if (j < MAX_NUMBER_OF_INDIVIDUAL_POINTS) { @@ -563,12 +564,12 @@ } j++; flag = false; - x = random.nextInt(n); - y = random.nextInt(n); + x = random.nextInt(MAX_RANDOM_NUMBER); + y = random.nextInt(MAX_RANDOM_NUMBER); break; } else { - x = random.nextInt(n); - y = random.nextInt(n); + x = random.nextInt(MAX_RANDOM_NUMBER); + y = random.nextInt(MAX_RANDOM_NUMBER); } } @@ -580,8 +581,8 @@ notCovInd.removeAll(posInd); notCoveredInd = notCovInd.size(); int k = 0; - x = random.nextInt(n); - y = random.nextInt(n); + x = random.nextInt(MAX_RANDOM_NUMBER); + y = random.nextInt(MAX_RANDOM_NUMBER); for (Individual ind : notCovInd) { flag = true; if (k < MAX_NUMBER_OF_INDIVIDUAL_POINTS) { @@ -603,12 +604,12 @@ } k++; flag = false; - x = random.nextInt(n); - y = random.nextInt(n); + x = random.nextInt(MAX_RANDOM_NUMBER); + y = random.nextInt(MAX_RANDOM_NUMBER); break; } else { - x = random.nextInt(n); - y = random.nextInt(n); + x = random.nextInt(MAX_RANDOM_NUMBER); + y = random.nextInt(MAX_RANDOM_NUMBER); } } @@ -685,32 +686,32 @@ } /** - * - * @return + * This method returns how much the old concept must be shifted. + * @return shift of the old concept */ public int getShiftOldConcept() { return shiftOldConcept; } /** - * - * @return + * This method returns how much the plus in the middle must be shifted. + * @return shift of the middle plus */ public int getShiftCovered() { return shiftCovered; } /** - * - * @return + * This method returns how much the new concept must be shifted. + * @return shift of the new concept */ public int getShiftNewConcept() { return shiftNewConcept; } /** - * - * @return + * This method returns how much the new concept must be shifted. + * @return shift of the new concept */ public int getShiftNewConceptX() { return shiftNewConceptX; @@ -732,17 +733,4 @@ public EvaluatedDescription getEvaluateddescription() { return eval; } - - public void resizePanel(int w, int h) { - this.setPreferredSize(new Dimension(WIDTH + w, HEIGHT + 100 + h)); - this.computeGraphics(w, h); - oldConcept = new Ellipse2D.Double(ELLIPSE_X_AXIS + (2 * adjustment), - ELLIPSE_Y_AXIS, WIDTH + w, HEIGHT + h); - newConcept = new Ellipse2D.Double(ELLIPSE_X_AXIS + shiftXAxis - + adjustment, ELLIPSE_Y_AXIS, WIDTH + distortionOld + w, HEIGHT - + distortionOld + h); - this.computeIndividualPoints(300 + w + h); - this.repaint(); - - } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/IndividualPoint.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/IndividualPoint.java 2009-05-06 10:53:22 UTC (rev 1740) +++ trunk/src/dl-learner/org/dllearner/tools/protege/IndividualPoint.java 2009-05-06 13:15:10 UTC (rev 1741) @@ -106,6 +106,10 @@ return individual; } + /** + * This method returns an ellipse of the individual for the GraphicalCoveragePanel. + * @return individual point of the individual + */ public Ellipse2D getIndividualPoint() { return circlePoint; } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2009-05-06 10:53:22 UTC (rev 1740) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2009-05-06 13:15:10 UTC (rev 1741) @@ -156,12 +156,25 @@ } + /** + * Returns the graphical coverage panel. + * @return graphical coverage panel + */ public GraphicalCoveragePanel getGraphicalCoveragePanel() { return p; } + + /** + * Returns the concept panel. + * @return concept panel + */ public JPanel getConceptPanel() { return conceptPanel; } + + /** + * Unsets the panel after plugin is closed. + */ public void unsetPanel() { unsetEverything(); conceptPanel.removeAll(); @@ -181,5 +194,4 @@ repaint(); } - -} \ No newline at end of file +} Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2009-05-06 10:53:22 UTC (rev 1740) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2009-05-06 13:15:10 UTC (rev 1741) @@ -49,9 +49,9 @@ public OptionPanel() { setLayout(new BorderLayout()); labelPanel = new JPanel(); - labelPanel.setLayout(new GridLayout(0,1)); + labelPanel.setLayout(new GridLayout(0, 1)); sliderPanel = new JPanel(); - sliderPanel.setLayout(new GridLayout(0,1)); + sliderPanel.setLayout(new GridLayout(0, 1)); minAccuracyLabel = new JLabel("noise in %: "); maxExecutionTimeLabel = new JLabel("maximum execution time: "); nrOfConceptsLabel = new JLabel("max. number of results: "); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2009-05-06 10:53:22 UTC (rev 1740) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2009-05-06 13:15:10 UTC (rev 1741) @@ -48,11 +48,19 @@ @Override public Set<OWLDescription> getDescriptions() { + if(view.getDLLearnerModel().getLearningAlgorithm() != null) { + if(view.getDLLearnerModel().getLearningAlgorithm().isRunning()) { + view.getDLLearnerModel().getLearningAlgorithm().stop(); + view.unsetEverything(); + } + } return view.getSolutions(); } @Override public boolean isValidInput() { + view.getSuggestClassPanel().getSuggestModel().clear(); + view.getSuggestClassPanel().repaint(); if(this.getAxiomType().toString().equals(EQUIVALENT_CLASS_STRING)) { view.makeView("equivalent class"); } else if(this.getAxiomType().toString().equals(SUPERCLASS_STRING)) { @@ -87,8 +95,4 @@ public void removeStatusChangedListener( InputVerificationStatusChangedListener arg0) { } - - - - -} \ No newline at end of file +} Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java 2009-05-06 10:53:22 UTC (rev 1740) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java 2009-05-06 13:15:10 UTC (rev 1741) @@ -54,7 +54,6 @@ /** * This is the constructor of the ReadingOntologyThread. * @param editorKit OWLEditorKit - * @param frame OWLFrame * @param v DL-Learner view * @param m DL-Learner model */ @@ -64,10 +63,18 @@ this.model = m; } + /** + * This method sets the view of the DL-Learner plugin. + * @param v DLLearnerView + */ public void setDLLearnerView(DLLearnerView v) { this.view = v; } + /** + * This method sets the model of the DL-Learner plugin. + * @param m DLLearnerModel + */ public void setDLLearnerModel(DLLearnerModel m) { this.model = m; } @@ -104,7 +111,6 @@ individual = reasoner.getIndividuals(concept); model.setIndividuals(individual); model.setHasIndividuals(hasIndividuals); - System.out.println("current: " + currentConcept); model.setCurrentConcept(currentConcept); view.getRunButton().setEnabled(true); break; @@ -192,6 +198,10 @@ } } + /** + * This method returns the NamedClass for the currently selected class. + * @return NamedClass of the currently selected class + */ public NamedClass getCurrentConcept() { return currentConcept; } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2009-05-06 10:53:22 UTC (rev 1740) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2009-05-06 13:15:10 UTC (rev 1741) @@ -28,36 +28,48 @@ import javax.swing.ListSelectionModel; /** - * This class is the panel for the suggest list. - * It shows the descriptions made by the DL-Learner. + * This class is the panel for the suggest list. It shows the descriptions made + * by the DL-Learner. + * * @author Christian Koetteritzsch - * + * */ public class SuggestClassPanel extends JPanel { - + private static final long serialVersionUID = 724628423947230L; - - // Description List - + + // Description List + private final JList descriptions; - - // Panel for the description list - + + // Panel for the description list + private final JPanel suggestPanel; - - //Scroll panel if the suggestions are longer than the Panel itself + // Scroll panel if the suggestions are longer than the Panel itself + private final JScrollPane suggestScroll; + private DefaultListModel suggestModel; + private DLLearnerModel model; + private DLLearnerView view; + /** - * This is the constructor for the suggest panel. - * It creates a new Scroll panel and puts the Suggest List in it. + * This is the constructor for the suggest panel. It creates a new Scroll + * panel and puts the Suggest List in it. + * @param m model of the DL-Learner + * @param v view of the DL-Learner */ - public SuggestClassPanel() { + public SuggestClassPanel(DLLearnerModel m, DLLearnerView v) { super(); + this.model = m; + this.view = v; + suggestModel = new DefaultListModel(); this.setLayout(new BorderLayout()); - //renders scroll bars if necessary - suggestScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - descriptions = new JList(); + // renders scroll bars if necessary + suggestScroll = new JScrollPane( + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + descriptions = new JList(suggestModel); descriptions.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); suggestPanel = new JPanel(); descriptions.setVisible(true); @@ -68,41 +80,86 @@ descriptions.setCellRenderer(new SuggestListCellRenderer()); add(BorderLayout.CENTER, suggestScroll); } - + /** - * this method adds an new Scroll Panel and returns the updated SuggestClassPanel. + * this method adds an new Scroll Panel and returns the updated + * SuggestClassPanel. + * * @return updated SuggestClassPanel */ public SuggestClassPanel updateSuggestClassList() { add(suggestScroll); return this; - + } + /** * This method is called after the model for the suggest list is updated. - * - * @param desc List model of descriptions made by the DL-Learner + * + * @param desc + * List model of descriptions made by the DL-Learner */ public void setSuggestList(DefaultListModel desc) { - descriptions.setModel(desc); + if (desc.size() != 0) { + if (suggestModel.size() == 0) { + for (int i = 0; i < desc.size(); i++) { + suggestModel.add(i, desc.get(i)); + } + } else { + for (int i = 0; i < suggestModel.size(); i++) { + if (!((SuggestListItem) suggestModel.get(i)).getValue() + .equals(((SuggestListItem) desc.get(i)).getValue())) { + descriptions.getSelectedIndex(); + suggestModel.set(i, desc.get(i)); + if (descriptions.getSelectedIndex() == i) { + view + .getMoreDetailForSuggestedConceptsPanel() + .renderDetailPanel( + model + .getCurrentlySelectedClassDescription(i)); + view.setGraphicalPanel(); + view.getMoreDetailForSuggestedConceptsPanel() + .repaint(); + + } + } + } + for (int i = suggestModel.getSize(); i < desc.size(); i++) { + suggestModel.add(i, desc.get(i)); + } + } + } descriptions.repaint(); repaint(); } + /** * This method returns the current Description list. + * * @return JList of Descriptions */ public JList getSuggestList() { return descriptions; } - + /** * This method adds the suggest list to the Mouse Listener. - * @param action ActionHandler + * + * @param action + * ActionHandler */ public void addSuggestPanelMouseListener(ActionHandler action) { descriptions.addMouseListener(action); - + } + /** + * Thsi method returns the list model for the suggest list. + * + * @return list model for the suggest list + */ + public DefaultListModel getSuggestModel() { + return suggestModel; + } + } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java 2009-05-06 10:53:22 UTC (rev 1740) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java 2009-05-06 13:15:10 UTC (rev 1741) @@ -28,8 +28,8 @@ public class SuggestListItem { private final Color color; - private final String value; - private final double accuracy; + private String value; + private double accuracy; /** * Constructor for the SuggestListItem. * @param c Color Color in which the text is painted. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |