From: <hee...@us...> - 2009-03-24 13:59:28
|
Revision: 1662 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1662&view=rev Author: heeroyuy Date: 2009-03-24 13:59:23 +0000 (Tue, 24 Mar 2009) Log Message: ----------- -split concept string on spaces -small changes on option panel -add own method to calculate if point is in ellipse 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/OptionPanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2009-03-24 09:14:51 UTC (rev 1661) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2009-03-24 13:59:23 UTC (rev 1662) @@ -102,7 +102,7 @@ */ public void actionPerformed(ActionEvent z) { - if (z.getActionCommand().equals("Suggest " + id +" description")) { + if (z.getActionCommand().equals("suggest class expression")) { model.setKnowledgeSource(); model.setReasoner(); model.setLearningProblem(); @@ -126,7 +126,7 @@ .getSuggestClassPanel().getSuggestList() .getSelectedValue()); } - String message = "class description\nadded"; + String message = "class expression\nadded"; view.renderErrorMessage(message); } if (z.getActionCommand().equals("")) { Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2009-03-24 09:14:51 UTC (rev 1661) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2009-03-24 13:59:23 UTC (rev 1662) @@ -290,7 +290,7 @@ e.printStackTrace(); } cm.applyConfigEntry(la, "useNegation", false); - cm.applyConfigEntry(la, "noisePercentage", 5.0); + cm.applyConfigEntry(la, "noisePercentage", view.getPosAndNegSelectPanel().getOptionPanel().getMinAccuracy()); cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view .getPosAndNegSelectPanel().getOptionPanel() .getMaxExecutionTime()); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2009-03-24 09:14:51 UTC (rev 1661) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2009-03-24 13:59:23 UTC (rev 1662) @@ -108,6 +108,7 @@ private final OWLEditorKit editorKit; private final JPanel learnerPanel; private final JScrollPane learnerScroll; + private static final int SCROLL_SPPED = 10; /** * The constructor for the DL-Learner tab in the class description @@ -133,7 +134,7 @@ adv = new JLabel("Advanced Settings"); advanced = new JToggleButton(icon); advanced.setVisible(true); - run = new JButton("Suggest " + label + " description"); + run = new JButton("suggest class expression"); accept = new JButton("ADD"); addButtonPanel = new JPanel(new BorderLayout()); sugPanel.addSuggestPanelMouseListener(action); @@ -141,13 +142,14 @@ errorMessage.setEditable(false); hint = new JTextArea(); hint.setEditable(false); - hint.setText("To get suggestions for class descriptions, please click the button above."); + hint.setText("To get suggestions for class expression, please click the button above."); learner = new JPanel(); advanced.setSize(20, 20); learner.setLayout(null); accept.setPreferredSize(new Dimension(260, 50)); advanced.setName("Advanced"); learnerScroll.setPreferredSize(new Dimension(600, 400)); + learnerScroll.getVerticalScrollBar().setUnitIncrement(SCROLL_SPPED); posPanel = new PosAndNegSelectPanel(model, action); detail = new MoreDetailForSuggestedConceptsPanel(model); this.addAcceptButtonListener(this.action); @@ -388,9 +390,9 @@ String error = "learning\nsuccessful"; String message = ""; if(isInconsistent) { - message = "Class descriptions marked red will lead to an inconsistent ontology. \nPlease double click on them to view detail information."; + message = "Class expressions marked red will lead to an inconsistent ontology. \nPlease double click on them to view detail information."; } else { - message = "To view details about why a class description was suggested, please click on it."; + message = "To view details about why a class expression was suggested, please click on it."; } run.setEnabled(true); // start the algorithm and print the best concept found Modified: trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2009-03-24 09:14:51 UTC (rev 1661) +++ trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2009-03-24 13:59:23 UTC (rev 1662) @@ -50,6 +50,8 @@ private static final int ELLIPSE_Y_AXIS = 5; private static final int MAX_NUMBER_OF_INDIVIDUAL_POINTS = 20; private static final int PLUS_SIZE = 5; + private static final int SUBSTRING_SIZE = 25; + private static final int SPACE_SIZE = 7; private static final String EQUI_STRING = "equivalent class"; private final String id; private int shiftXAxis; @@ -80,6 +82,8 @@ private int centerX; private int centerY; private final Random random; + private final Color darkGreen; + private final Color darkRed; private final MoreDetailForSuggestedConceptsPanel panel; /** @@ -103,8 +107,10 @@ this.repaint(); eval = desc; model = m; - panel = p;; + panel = p; id = model.getID(); + darkGreen = new Color(0, 100, 0); + darkRed = new Color(205, 0, 0); random = new Random(); conceptNew = concept; conceptVector = new Vector<String>(); @@ -132,15 +138,21 @@ AlphaComposite ac = AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.5f); - g2D.setColor(Color.YELLOW); - g2D.fill(oldConcept); - g2D.drawString(model.getOldConceptOWLAPI().toString(), 310, 10); + g2D.setColor(Color.BLACK); + g2D.drawString(model.getOldConceptOWLAPI().toString(), 320, 10); g2D.setColor(Color.ORANGE); + g2D.fillOval(310, 20, 9, 9); + g2D.setColor(Color.black); int p = 30; for (int i = 0; i < conceptVector.size(); i++) { - g2D.drawString(conceptVector.get(i), 310, p); + g2D.drawString(conceptVector.get(i), 320, p); p = p + 20; } + + g2D.setColor(Color.YELLOW); + g2D.fill(oldConcept); + g2D.fillOval(310, 0, 9, 9); + g2D.setColor(Color.ORANGE); g2D.setComposite(ac); g2D.fill(newConcept); g2D.setColor(Color.BLACK); @@ -223,7 +235,8 @@ + shiftNewConcept, y2 + 1); } - if (((EvaluatedDescriptionClass) eval).getAddition() != 1.0 && ((EvaluatedDescriptionClass) eval).getCoverage() == 1.0) { + if (((EvaluatedDescriptionClass) eval).getAddition() != 1.0 + && ((EvaluatedDescriptionClass) eval).getCoverage() == 1.0) { g2D.drawLine(x1 - 1 + shiftNewConceptX, y1 - 1 + shiftNewConcept, x2 + 1 + shiftNewConceptX, y1 - 1 + shiftNewConcept); @@ -256,14 +269,14 @@ } for (int i = 0; i < posCovIndVector.size(); i++) { - g2D.setColor(Color.GREEN); + g2D.setColor(darkGreen); g2D.drawString(posCovIndVector.get(i).getPoint(), posCovIndVector.get(i).getXAxis(), posCovIndVector.get( i).getYAxis()); } for (int i = 0; i < posNotCovIndVector.size(); i++) { - g2D.setColor(Color.RED); + g2D.setColor(darkRed); g2D.drawString(posNotCovIndVector.get(i).getPoint(), posNotCovIndVector.get(i).getXAxis(), posNotCovIndVector.get(i).getYAxis()); @@ -335,17 +348,37 @@ shiftNewConcept = 2 * shiftNewConceptX; } } - + int i = conceptNew.length(); - int z = 0; - while(i > 0) { - if(i >= 39 ) { - z = 39; - } else { - z = conceptNew.length(); + while (i > 0) { + int sub = conceptNew.indexOf(" "); + String subString = conceptNew.substring(0, sub) + " "; + conceptNew = conceptNew.replace(conceptNew.substring(0, sub+1), ""); + while(sub < SUBSTRING_SIZE) { + if(conceptNew.length() > 0 && conceptNew.contains(" ")) { + sub = conceptNew.indexOf(" "); + if(subString.length() + sub < SUBSTRING_SIZE) { + subString = subString + conceptNew.substring(0, sub) + " "; + conceptNew = conceptNew.replace(conceptNew.substring(0, sub+1), ""); + System.out.println("string: " + subString + " lenght: " + subString.length()); + sub = subString.length(); + } else { + break; + } + } else { + if(subString.length() + conceptNew.length() > SUBSTRING_SIZE + SPACE_SIZE) { + conceptVector.add(subString); + subString = conceptNew; + conceptNew = ""; + break; + } else { + subString = subString + conceptNew; + conceptNew = ""; + break; + } + } } - conceptVector.add(conceptNew.substring(0, z)); - conceptNew = conceptNew.replace(conceptNew.substring(0, z), ""); + conceptVector.add(subString); i = conceptNew.length(); } } @@ -362,13 +395,14 @@ flag = true; if (i < MAX_NUMBER_OF_INDIVIDUAL_POINTS) { while (flag) { - if (newConcept.contains(x, y) - && oldConcept.contains(x, y) - && !(x >= this.getX1() + this.getShiftCovered()-5 + if (this.isInCircle(x, y, newConcept) + && this.isInCircle(x, y, oldConcept) + && !(x >= this.getX1() + this.getShiftCovered() + - 5 && x <= this.getX2() - + this.getShiftCovered()+5 - && y >= this.getY1()-5 && y <= this - .getY2()+5)) { + + this.getShiftCovered() + 5 + && y >= this.getY1() - 5 && y <= this + .getY2() + 5)) { posCovIndVector.add(new IndividualPoint("*", (int) x, (int) y, ind.toString())); i++; @@ -395,21 +429,23 @@ flag = true; if (j < MAX_NUMBER_OF_INDIVIDUAL_POINTS) { while (flag) { - if (!oldConcept.contains(x, y) - && newConcept.contains(x, y) + if (!this.isInCircle(x, y, oldConcept) + && this.isInCircle(x, y, newConcept) && !(x >= this.getX1() - + this.getShiftNewConcept()-5 + + this.getShiftNewConcept() - 5 && x <= this.getX2() - + this.getShiftNewConcept()+5 - && y >= this.getY1()-5 && y <= this - .getY2()+5) && !(x >= this.getX1() - + this.getShiftNewConceptX()-5 + + this.getShiftNewConcept() + 5 + && y >= this.getY1() - 5 && y <= this + .getY2() + 5) + && !(x >= this.getX1() + + this.getShiftNewConceptX() - 5 && x <= this.getX2() - + this.getShiftNewConceptX()+5 + + this.getShiftNewConceptX() + + 5 && y >= this.getY1() - + this.getShiftNewConcept()-5 && y <= this - .getY2()+5 - + this.getShiftNewConcept())) { + + this.getShiftNewConcept() - 5 && y <= this + .getY2() + + 5 + this.getShiftNewConcept())) { if (id.equals(EQUI_STRING)) { posNotCovIndVector.add(new IndividualPoint("*", (int) x, (int) y, ind.toString())); @@ -441,14 +477,14 @@ flag = true; if (k < MAX_NUMBER_OF_INDIVIDUAL_POINTS) { while (flag) { - if (oldConcept.contains(x, y) - && !newConcept.contains(x, y) - && !(x >= this.getX1()-5 + if (this.isInCircle(x, y, oldConcept) + && !this.isInCircle(x, y, newConcept) + && !(x >= this.getX1() - 5 - this.getShiftOldConcept() - && x <= this.getX2()+5 + && x <= this.getX2() + 5 - this.getShiftOldConcept() - && y >= this.getY1()-5 && y <= this - .getY2()+5)) { + && y >= this.getY1() - 5 && y <= this + .getY2() + 5)) { posNotCovIndVector.add(new IndividualPoint("*", (int) x, (int) y, ind.toString())); k++; @@ -582,4 +618,15 @@ public EvaluatedDescription getEvaluateddescription() { return eval; } + + public boolean isInCircle(double x, double y, Ellipse2D ell) { + int r = (WIDTH / 2) * (WIDTH / 2); + int n = (int) ((x - ell.getCenterX()) * (x - ell.getCenterX())) + + (int) ((y - ell.getCenterY()) * (y - ell.getCenterY())); + if (n <= r) { + return true; + } else { + return false; + } + } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2009-03-24 09:14:51 UTC (rev 1661) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2009-03-24 13:59:23 UTC (rev 1662) @@ -53,12 +53,12 @@ nrOfConceptsLabel = new JLabel("maximum number of results"); nrOfConceptsLabel.setBounds(5, 80, 150, 40); - minAccuracy = new JSlider(50, 100, 90); + minAccuracy = new JSlider(0, 50, 5); minAccuracy.setPaintTicks(true); minAccuracy.setMajorTickSpacing(10); minAccuracy.setMinorTickSpacing(1); minAccuracy.setPaintLabels(true); - minAccuracy.setBounds(160, 0, 200, 40); + minAccuracy.setBounds(200, 0, 200, 40); maxExecutionTime = new JSlider(2, 20, 8); @@ -66,7 +66,7 @@ maxExecutionTime.setMajorTickSpacing(5); maxExecutionTime.setMinorTickSpacing(1); maxExecutionTime.setPaintLabels(true); - maxExecutionTime.setBounds(160, 40, 200, 40); + maxExecutionTime.setBounds(200, 40, 200, 40); nrOfConcepts = new JSlider(2, 20, 10); @@ -74,7 +74,7 @@ nrOfConcepts.setMajorTickSpacing(2); nrOfConcepts.setMinorTickSpacing(1); nrOfConcepts.setPaintLabels(true); - nrOfConcepts.setBounds(160, 80, 200, 40); + nrOfConcepts.setBounds(200, 80, 200, 40); add(minAccuracyLabel); add(minAccuracy); @@ -89,7 +89,7 @@ * @return double minAccuracy */ public double getMinAccuracy() { - int acc = minAccuracy.getValue(); + double acc = minAccuracy.getValue(); accuracy = (acc/100.0); return accuracy; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |