Examples of JmodelStationDefinition


Examples of jmt.gui.jmodel.definitions.JmodelStationDefinition

   * @return created component
   *
   * Author: Bertoli Marco
   */
  public CellComponent createComponent(String className) {
    JmodelStationDefinition sd = mediator.getStationDefinition();
    return new CellComponent(sd.addStation(getComponentType(className)), sd);
  }
View Full Code Here

Examples of jmt.gui.jmodel.definitions.JmodelStationDefinition

  /**
   * Deletes a JmtCell component removing its data structure
   * @param cell component to be eliminated
   */
  public void deleteCell(JmtCell cell) {
    JmodelStationDefinition sd = mediator.getStationDefinition();
    sd.deleteStation(((CellComponent) cell.getUserObject()).getKey());
  }
View Full Code Here

Examples of jmt.gui.jmodel.definitions.JmodelStationDefinition

   * Will be used to avoid sovrapposition of nodes on the graph before placement.
   * @param className name of the *Cell that will be instantiated
   * @return predicted dimensions of Node
   */
  public Dimension predictCellSize(String className) {
    JmodelStationDefinition sd = mediator.getStationDefinition();
    String path = "jmt.gui.jmodel.JGraphMod.";
    ImageIcon icon = null;
    // Using reflection to access to public ICON field on given class
    try {
      String iconName = (String) (Class.forName(path + className)).getField("ICON").get(null);
      icon = JMTImageLoader.loadImage(iconName);
    } catch (IllegalAccessException e) {
      System.out.println("Error: A security manager has blocked reflection...");
      e.printStackTrace();
      return null;
    } catch (NoSuchFieldException e) {
      System.out.println("Error: Field 'ICON' was not found in '" + className + "'. This is needed for reflection.");
      e.printStackTrace();
      return null;
    } catch (ClassNotFoundException e) {
      System.out.println("Error: Trying to get size fron a Cell class that does not exist");
      e.printStackTrace();
      return null;
    }

    String name = sd.previewStationName(getComponentType(className));

    Dimension cellDimension = new Dimension(icon.getIconWidth(), icon.getIconHeight());
    // Gets the graph font
    Font font = mediator.getGraph().getFont();
    // Gets the graphical context
View Full Code Here

Examples of jmt.gui.jmodel.definitions.JmodelStationDefinition

   * Copy current selected Stations and Edges into clipboard
   */
  public void copy() {
    flush();
    // Gets selected cells
    JmodelStationDefinition sd = mediator.getStationDefinition();
    JGraph graph = mediator.getGraph();
    Object cells[] = graph.getDescendants(graph.getSelectionCells());
    // Temp variables
    Object key; // Station key
    JmtEdge edgetmp;
    JmtCell celltmp;
    Point2D location; // position of a station
    // Saves into data structure selected stations (including position) and links
    for (Object cell : cells) {
      if (cell instanceof JmtCell) {
        celltmp = (JmtCell) cell;
        key = ((CellComponent) celltmp.getUserObject()).getKey();
        stations.put(key, sd.serializeStation(key));
        location = mediator.getCellCoordinates(celltmp);
        stationpositions.put(key, location);
        // Initialize 'zero' as the upper-leftmost point of selected stations
        // Will be used as a bias while pasting
        if (zero == null) {
View Full Code Here

Examples of jmt.gui.jmodel.definitions.JmodelStationDefinition

    Point2D newpos; // New station position
    if (stations == null || stations.size() == 0) {
      return;
    }

    JmodelStationDefinition sd = mediator.getStationDefinition();

    // Recreates all stations and position them
    keys = stations.keySet().iterator();
    while (keys.hasNext()) {
      oldkey = keys.next();
      // Creates a new station with parameters got from previous copy operation
      newkey = sd.deserializeStation(stations.get(oldkey));
      newcell = mediator.getCellFactory().createCell(sd.getStationType(newkey) + "Cell", new CellComponent(newkey, sd));
      tempkey.put(oldkey, newkey);
      // Calculates where this station should be put
      oldpos = stationpositions.get(oldkey);
      newpos = new Point2D.Double(where.getX() + oldpos.getX() - zero.getX(), where.getY() + oldpos.getY() - zero.getY());
      // Insert created station into JGraph. Finds the first empty position going
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.