Clover coverage report - Maven Clover report
Coverage timestamp: Thu Oct 11 2007 08:41:48 CEST
file stats: LOC: 93   Methods: 5
NCLOC: 65   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SimplePointCreationTool.java 25% 61.1% 80% 59.3%
coverage coverage
 1    /*
 2    * Copyright (C) 2007 Eric MIGNOT - mignots.eric@free.fr
 3    *
 4    * This library is free software; you can redistribute it and/or
 5    * modify it under the terms of the GNU Lesser General Public
 6    * License as published by the Free Software Foundation; either
 7    * version 2.1 of the License, or (at your option) any later version.
 8    *
 9    * This library is distributed in the hope that it will be useful,
 10    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12    * Lesser General Public License for more details.
 13    *
 14    * You should have received a copy of the GNU Lesser General Public
 15    * License along with this library; if not, write to the Free Software
 16    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 17    */
 18   
 19    package org.ericmignot.modeler.gui.palette;
 20   
 21    import java.awt.Point;
 22   
 23    import javax.swing.ImageIcon;
 24    import javax.swing.JToggleButton;
 25   
 26    import org.ericmignot.modeler.action.MoveAction;
 27    import org.ericmignot.modeler.action.SimplePointCreationAction;
 28    import org.ericmignot.modeler.data.Link;
 29    import org.ericmignot.modeler.data.SimplePoint;
 30    import org.ericmignot.modeler.gui.StaticValues;
 31    import org.ericmignot.modeler.gui.workarea.Item;
 32    import org.ericmignot.modeler.gui.workarea.LinkItem;
 33    import org.ericmignot.modeler.util.action.ActionException;
 34    import org.ericmignot.modeler.util.action.NotifyableAction;
 35   
 36    public class SimplePointCreationTool extends DragAndDropPaletteTool
 37    {
 38    protected SimplePoint createdPoint;
 39   
 40  0 public JToggleButton getButton()
 41    {
 42  0 if (this.button == null)
 43    {
 44  0 this.button = new JToggleButton(
 45    StaticValues.getInstance().get("Design.Palette.LinkPoint", "Link Point"),
 46    new ImageIcon(this.getClass().getClassLoader().getResource(
 47    "org/ericmignot/modeler/gui/palette/point.gif")));
 48  0 this.button.setToolTipText(StaticValues.getInstance().get("Design.Palette.LinkPointTooltip", "Link point creation tool"));
 49    }
 50  0 return this.button;
 51    }
 52   
 53  6 public boolean isItemCandidate(Item item)
 54    {
 55  6 return (item != null && (item instanceof LinkItem));
 56    }
 57   
 58  6 protected NotifyableAction getAction(Item item, int x, int y)
 59    {
 60  6 if (((LinkItem)item).acceptPointForUserInteraction(x, y))
 61    {
 62  6 SimplePoint newPoint = new SimplePoint();
 63  6 newPoint.setCenter(x, y);
 64  6 SimplePointCreationAction action = new SimplePointCreationAction(
 65    (Link) item.getBusinessObject(),
 66    newPoint,
 67    this.getController().getModel()
 68    );
 69  6 return action;
 70    }
 71  0 return null;
 72    }
 73   
 74  6 protected void mousePressedImpl()
 75    {
 76  6 try {
 77  6 this.createdPoint = (SimplePoint) this.mousePressedAction.execute(null);
 78    } catch (ActionException e) {
 79  0 e.printStackTrace();
 80    }
 81    }
 82   
 83  4 protected void mouseDraggedImpl(Point delta)
 84    {
 85  4 MoveAction action = new MoveAction(this.createdPoint, delta);
 86  4 try {
 87  4 action.execute(null);
 88    } catch (ActionException e) {
 89  0 e.printStackTrace();
 90    }
 91    }
 92   
 93    }