From: <hee...@us...> - 2009-03-16 10:23:26
|
Revision: 1651 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1651&view=rev Author: heeroyuy Date: 2009-03-16 10:23:18 +0000 (Mon, 16 Mar 2009) Log Message: ----------- -draw points at a random point on graphical panel 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/GraphicalCoveragePanel.java trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanelHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanelHandler.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2009-03-12 14:51:39 UTC (rev 1650) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2009-03-16 10:23:18 UTC (rev 1651) @@ -141,12 +141,6 @@ view.setExamplePanelVisible(toggled); } } - if (z.getActionCommand().equals("Why")) { - view.getMoreDetailForSuggestedConceptsPanel().renderDetailPanel( - evaluatedDescription); - view.setGraphicalPanel(); - view.getMoreDetailForSuggestedConceptsPanel().repaint(); - } } /** Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2009-03-12 14:51:39 UTC (rev 1650) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2009-03-16 10:23:18 UTC (rev 1651) @@ -184,8 +184,8 @@ sources = new HashSet<KnowledgeSource>(); } - public void setID(String id) { - this.id = id; + public void setID(String d) { + this.id = d; } /** * This method initializes the SimpleSuggestionLearningAlgorithm and adds @@ -521,6 +521,10 @@ public void setInstancesCount(int i) { instancesCount = i; } + + public String getID() { + return id; + } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2009-03-12 14:51:39 UTC (rev 1650) +++ trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2009-03-16 10:23:18 UTC (rev 1651) @@ -25,6 +25,7 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Ellipse2D; +import java.util.Random; import java.util.Set; import java.util.Vector; @@ -49,7 +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 GAP = 20; + private static final String EQUI_STRING = "equivalent class"; + private final String id; private int shiftXAxis; private int distortionOld; private final Ellipse2D oldConcept; @@ -60,6 +62,7 @@ private final String conceptNew; private final Vector<IndividualPoint> posCovIndVector; private final Vector<IndividualPoint> posNotCovIndVector; + private final Vector<IndividualPoint> additionalIndividuals; private final Vector<IndividualPoint> points; private final GraphicalCoveragePanelHandler handler; private int adjustment; @@ -75,6 +78,7 @@ private int y2; private int centerX; private int centerY; + private final Random random; private final MoreDetailForSuggestedConceptsPanel panel; /** @@ -99,9 +103,12 @@ eval = desc; model = m; panel = p; + id = model.getID(); + random = new Random(); conceptNew = concept; posCovIndVector = new Vector<IndividualPoint>(); posNotCovIndVector = new Vector<IndividualPoint>(); + additionalIndividuals = new Vector<IndividualPoint>(); points = new Vector<IndividualPoint>(); this.computeGraphics(); handler = new GraphicalCoveragePanelHandler(this, desc, model); @@ -255,6 +262,13 @@ posNotCovIndVector.get(i).getXAxis(), posNotCovIndVector.get(i).getYAxis()); } + + for (int i = 0; i < additionalIndividuals.size(); i++) { + g2D.setColor(Color.BLACK); + g2D.drawString(additionalIndividuals.get(i).getPoint(), + additionalIndividuals.get(i).getXAxis(), + additionalIndividuals.get(i).getYAxis()); + } this.setVisible(true); panel.repaint(); } @@ -292,22 +306,22 @@ if (eval != null) { coveredIndividualSize = ((EvaluatedDescriptionClass) eval) .getCoveredInstances().size(); - double newConcept = ((EvaluatedDescriptionClass) eval) + double newConcepts = ((EvaluatedDescriptionClass) eval) .getAddition(); - double oldConcept = ((EvaluatedDescriptionClass) eval) + double oldConcepts = ((EvaluatedDescriptionClass) eval) .getCoverage(); shiftNewConcept = 0; shiftOldConcept = 0; shiftNewConceptX = 0; shiftCovered = 0; if (coveredIndividualSize == 0) { - shiftNewConcept = (int) Math.round((WIDTH / 2.0) * newConcept); + shiftNewConcept = (int) Math.round((WIDTH / 2.0) * newConcepts); } else if (additionalIndividualSize != coveredIndividualSize) { shiftNewConcept = (int) Math.round((WIDTH / 2.0) - * (newConcept + (1 - oldConcept))); - shiftOldConcept = (int) Math.round((WIDTH / 2.0) * oldConcept); + * (newConcepts + (1 - oldConcepts))); + shiftOldConcept = (int) Math.round((WIDTH / 2.0) * oldConcepts); shiftCovered = (int) Math.round((WIDTH / 2.0) - * (1 - oldConcept)); + * (1 - oldConcepts)); } if (((EvaluatedDescriptionClass) eval).getAddition() != 1.0) { shiftCovered = (int) Math.round((WIDTH / 2.0) * 0.625); @@ -322,46 +336,33 @@ Set<Individual> posInd = ((EvaluatedDescriptionClass) eval) .getCoveredInstances(); int i = 0; - double x = 100; - double y = 100; + double x = random.nextInt(300); + double y = random.nextInt(300); boolean flag = true; for (Individual ind : posInd) { flag = true; if (i < MAX_NUMBER_OF_INDIVIDUAL_POINTS) { while (flag) { - if (x >= oldConcept.getMaxX()) { - x = (int) oldConcept.getMinX(); - y = y + GAP; - } + if (newConcept.contains(x, y) + && oldConcept.contains(x, y) + && !(x >= this.getX1() + this.getShiftCovered()-5 + && x <= this.getX2() + + this.getShiftCovered()+5 + && y >= this.getY1()-5 && y <= this + .getY2()+5)) { + posCovIndVector.add(new IndividualPoint("*", + (int) x, (int) y, ind.toString())); + i++; + flag = false; - if (y >= oldConcept.getMaxY()) { - y = (int) oldConcept.getMinY(); - } - - if (x >= newConcept.getMaxX()) { - x = (int) newConcept.getMinX(); - y = y + GAP; - } - - if (y >= newConcept.getMaxY()) { - y = (int) newConcept.getMinY(); + x = random.nextInt(300); + y = random.nextInt(300); break; + } else { + x = random.nextInt(300); + y = random.nextInt(300); } - while (x < newConcept.getMaxX()) { - - if (newConcept.contains(x, y) - && oldConcept.contains(x, y)) { - posCovIndVector.add(new IndividualPoint("*", - (int) x, (int) y, ind.toString())); - i++; - flag = false; - x = x + GAP; - break; - } else { - x = x + GAP; - } - } } } } @@ -369,36 +370,44 @@ Set<Individual> posNotCovInd = ((EvaluatedDescriptionClass) eval) .getAdditionalInstances(); int j = 0; - x = 100; - y = 100; + x = random.nextInt(300); + y = random.nextInt(300); for (Individual ind : posNotCovInd) { flag = true; if (j < MAX_NUMBER_OF_INDIVIDUAL_POINTS) { while (flag) { - if (x >= newConcept.getMaxX()) { - x = (int) oldConcept.getMinX(); - y = y + GAP; - } - - if (y >= newConcept.getMaxY()) { - y = (int) oldConcept.getMinY(); - break; - } - - while (x < newConcept.getMaxX()) { - - if (!oldConcept.contains(x, y) - && newConcept.contains(x, y)) { + if (!oldConcept.contains(x, y) + && newConcept.contains(x, y) + && !(x >= this.getX1() + + this.getShiftNewConcept()-5 + && x <= this.getX2() + + this.getShiftNewConcept()+5 + && y >= this.getY1()-5 && y <= this + .getY2()+5) && !(x >= this.getX1() + + this.getShiftNewConceptX()-5 + && x <= this.getX2() + + this.getShiftNewConceptX()+5 + && y >= this.getY1() + + this.getShiftNewConcept()-5 && y <= this + .getY2()+5 + + this.getShiftNewConcept())) { + if (id.equals(EQUI_STRING)) { posNotCovIndVector.add(new IndividualPoint("*", (int) x, (int) y, ind.toString())); - j++; - flag = false; - x = x + GAP; - break; } else { - x = x + GAP; + additionalIndividuals.add(new IndividualPoint( + "*", (int) x, (int) y, ind.toString())); } + j++; + flag = false; + x = random.nextInt(300); + y = random.nextInt(300); + break; + } else { + x = random.nextInt(300); + y = random.nextInt(300); } + } } } @@ -407,41 +416,38 @@ model.getCurrentConcept()); notCovInd.removeAll(posInd); int k = 0; - x = 100; - y = 100; + x = random.nextInt(300); + y = random.nextInt(300); for (Individual ind : notCovInd) { flag = true; if (k < MAX_NUMBER_OF_INDIVIDUAL_POINTS) { while (flag) { - if (x >= oldConcept.getMaxX()) { - x = (int) oldConcept.getMinX(); - y = y + GAP; - } - - if (y >= oldConcept.getMaxY()) { - y = (int) oldConcept.getMinY(); + if (oldConcept.contains(x, y) + && !newConcept.contains(x, y) + && !(x >= this.getX1()-5 + - this.getShiftOldConcept() + && x <= this.getX2()+5 + - this.getShiftOldConcept() + && y >= this.getY1()-5 && y <= this + .getY2()+5)) { + posNotCovIndVector.add(new IndividualPoint("*", + (int) x, (int) y, ind.toString())); + k++; + flag = false; + x = random.nextInt(300); + y = random.nextInt(300); break; + } else { + x = random.nextInt(300); + y = random.nextInt(300); } - while (x < oldConcept.getMaxX()) { - - if (oldConcept.contains(x, y) - && !newConcept.contains(x, y)) { - posNotCovIndVector.add(new IndividualPoint("*", - (int) x, (int) y, ind.toString())); - k++; - flag = false; - x = x + GAP; - break; - } else { - x = x + GAP; - } - } } } } points.addAll(posCovIndVector); points.addAll(posNotCovIndVector); + points.addAll(additionalIndividuals); } } @@ -473,43 +479,87 @@ return panel; } + /** + * Returns the min. x value of the plus. + * + * @return int min X Value + */ public int getX1() { return x1; } + /** + * Returns the max. x value of the plus. + * + * @return int max X Value + */ public int getX2() { return x2; } + /** + * Returns the min. y value of the plus. + * + * @return int min Y Value + */ public int getY1() { return y1; } + /** + * Returns the max. y value of the plus. + * + * @return int max Y Value + */ public int getY2() { return y2; } + /** + * + * @return + */ public int getShiftOldConcept() { return shiftOldConcept; } + /** + * + * @return + */ public int getShiftCovered() { return shiftCovered; } + /** + * + * @return + */ public int getShiftNewConcept() { return shiftNewConcept; } + /** + * + * @return + */ public int getShiftNewConceptX() { return shiftNewConceptX; } + /** + * Unsets the panel after plugin is closed. + */ public void unsetPanel() { this.removeAll(); eval = null; } - + + /** + * Returns the currently selected evaluated description. + * + * @return EvaluatedDescription + */ public EvaluatedDescription getEvaluateddescription() { return eval; } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanelHandler.java 2009-03-12 14:51:39 UTC (rev 1650) +++ trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanelHandler.java 2009-03-16 10:23:18 UTC (rev 1651) @@ -47,12 +47,12 @@ private final EvaluatedDescription description; private final DLLearnerModel model; private final JPopupMenu popup; - + /** * This is the constructor for the handler. - * - * @param p - * GraphicalCoveragePanel + * @param p GraphicalCoveragePanel + * @param eval EvaluatedDescription + * @param m DLLearnerModel */ public GraphicalCoveragePanelHandler(GraphicalCoveragePanel p, EvaluatedDescription eval, DLLearnerModel m) { Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanelHandler.java 2009-03-12 14:51:39 UTC (rev 1650) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanelHandler.java 2009-03-16 10:23:18 UTC (rev 1651) @@ -1,3 +1,22 @@ +/** + * Copyright (C) 2007-2009, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ package org.dllearner.tools.protege; import java.beans.PropertyChangeEvent; @@ -3,6 +22,16 @@ import java.beans.PropertyChangeListener; +/** + * This is the Listener for the MoreDetailForSuggestedConceptsPanel. + * @author Christian Koetteritzsch + * + */ public class MoreDetailForSuggestedConceptsPanelHandler implements PropertyChangeListener{ private final MoreDetailForSuggestedConceptsPanel panel; + + /** + * This is the constructor of the class. + * @param m MoreDetailForSuggestedConceptsPanel + */ public MoreDetailForSuggestedConceptsPanelHandler(MoreDetailForSuggestedConceptsPanel m) { panel = m; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |