/**
   * Returns a shallow copy of this graph instance. Neither edges nor vertices are cloned.
   *
   * @return a shallow copy of this set.
   * @throws RuntimeException
   * @see java.lang.Object#clone()
   */
  public Object clone() {
    try {
      TypeUtil<AbstractBaseGraph<V, E>> typeDecl = null;

      AbstractBaseGraph<V, E> newGraph = TypeUtil.uncheckedCast(super.clone(), typeDecl);

      newGraph.edgeMap = new LinkedHashMap<E, IntrusiveEdge>();

      newGraph.edgeFactory = this.edgeFactory;
      newGraph.unmodifiableEdgeSet = null;
      newGraph.unmodifiableVertexSet = null;

      // NOTE:  it's important for this to happen in an object
      // method so that the new inner class instance gets associated with
      // the right outer class instance
      newGraph.specifics = newGraph.createSpecifics();

      Graphs.addGraph(newGraph, this);

      return newGraph;
    } catch (CloneNotSupportedException e) {
      e.printStackTrace();
      throw new RuntimeException();
    }
  }
Beispiel #2
0
  protected void reset() {
    paused = false;
    Sprite.spriteContext = this;
    sprites.clear();

    try {
      level = currentLevel.clone();
    } catch (CloneNotSupportedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    level.resetSpriteTemplate();

    layer = new LevelRenderer(level, graphicsConfiguration, 320, 240);

    double oldX = 0;

    if (mario != null) oldX = mario.x;

    mario = new Mario(this);
    sprites.add(mario);
    startTime = 1;

    timeLeft = 200 * 15;
    Art.startMusic(1);
    tick = 0;
    //        recorder = new DataRecorder(this,level,keys,gametype);
    if (recorder != null) {
      recorder.detailedLog = "";
    }
    gameStarted = false;
  }
 /** Return a shallow copy of this ref. */
 public Object clone() {
   try {
     LiveRef newRef = (LiveRef) super.clone();
     return newRef;
   } catch (CloneNotSupportedException e) {
     throw new InternalError(e.toString());
   }
 }
 @Override
 public Object clone() throws CloneNotSupportedException {
   try {
     return super.clone();
   } catch (CloneNotSupportedException e) {
     throw new InternalError(e.getMessage());
   }
 }
  /**
   * Contract: get routes from shedule with StationInfo from filter; if in the filter exist date
   * then compare it with the date when train will be on the station for this route
   *
   * @param filter contains StationInfo fow which need SheduleItems info and date when train need on
   *     the station
   * @return SheduleItems that satisfy to conditions
   */
  @Transactional(readOnly = true)
  public List<SheduleItemEntity> searchByStation(SheduleFilter filter) {
    List<SheduleItemEntity> sheduleItemsList = new ArrayList<SheduleItemEntity>();

    List<StationInfoEntity> stationInfoList = new ArrayList<StationInfoEntity>();
    stationInfoList.add(filter.getStationInfo());
    for (SheduleItemEntity sheduleItem : this.sheduleDAO.getByStations(stationInfoList)) {

      StationEntity station = null;
      for (StationEntity stationInRoute : sheduleItem.getRoute().getStationsList()) {
        if (stationInRoute.getStationInfo().equals(filter.getStationInfo())) {
          station = stationInRoute;
        }
      }

      if (station != null) {
        GregorianCalendar dateCondition = null;
        if (filter.getDate() != null) {
          dateCondition = new GregorianCalendar();
          dateCondition.setTime(filter.getDate());
          dateCondition =
              new GregorianCalendar(
                  dateCondition.get(Calendar.YEAR),
                  dateCondition.get(Calendar.MONTH),
                  dateCondition.get(Calendar.DAY_OF_MONTH));
        }

        GregorianCalendar sheduleItemDate = null;
        if (dateCondition != null) {
          sheduleItemDate = new GregorianCalendar();
          sheduleItemDate.setTime(sheduleItem.getDepartureDate());
          sheduleItemDate.add(Calendar.MINUTE, station.getTimeOffset());
          sheduleItemDate =
              new GregorianCalendar(
                  sheduleItemDate.get(Calendar.YEAR),
                  sheduleItemDate.get(Calendar.MONTH),
                  sheduleItemDate.get(Calendar.DAY_OF_MONTH));
        }

        if ((dateCondition != null
                && sheduleItemDate != null
                && dateCondition.equals(sheduleItemDate))
            || dateCondition == null) {
          try {
            SheduleItemEntity cloneSheduleItem = (SheduleItemEntity) sheduleItem.clone();
            cloneSheduleItem.getRoute().getStationsList().clear();
            cloneSheduleItem.getRoute().getStationsList().add(station);
            sheduleItemsList.add(cloneSheduleItem);
          } catch (CloneNotSupportedException exc) {
            exc.printStackTrace();
            LOGGER.warn(exc);
          }
        }
      }
    }

    return sheduleItemsList;
  }
 public Liner clone() {
   try {
     return (Liner) super.clone();
   } catch (CloneNotSupportedException ex) {
     InternalError error = new InternalError(ex.getMessage());
     error.initCause(ex);
     throw error;
   }
 }
Beispiel #7
0
 /**
  * Clones this Step.
  *
  * @return a clone of this step
  */
 public Object clone() {
   try {
     Step step = (Step) super.clone();
     step.points = new TPoint[points.length];
     step.screenPoints = new Point[points.length];
     step.marks = new HashMap<TrackerPanel, Mark>();
     return step;
   } catch (CloneNotSupportedException ex) {
     ex.printStackTrace();
   }
   return null;
 }
 @Override
 protected ModuleBasedConfiguration createInstance() {
   try {
     return new TestNGConfiguration(
         getName(),
         getProject(),
         (TestData) data.clone(),
         TestNGConfigurationType.getInstance().getConfigurationFactories()[0]);
   } catch (CloneNotSupportedException e) {
     // can't happen right?
     e.printStackTrace();
   }
   return null;
 }
  /**
   * Merges the layer at <code>index</code> with the layer below it
   *
   * @see MapLayer#mergeOnto
   * @param index the index of the layer to merge down
   */
  public void mergeLayerDown(int index) {
    if (index - 1 < 0) {
      throw new RuntimeException("Can't merge down bottom layer.");
    }

    // TODO: We're not accounting for different types of layers!!!
    TileLayer ntl;
    try {
      ntl = (TileLayer) getLayer(index - 1).clone();
    } catch (CloneNotSupportedException e) {
      e.printStackTrace();
      return;
    }

    getLayer(index).mergeOnto(ntl);
    setLayer(index - 1, ntl);
    removeLayer(index);
  }
  /**
   * Contract: get routes from shedule with StationInfos from filter; check that arrival station in
   * selected route is after departure station; if exist start or end of date range in the filter
   * then check date conditions
   *
   * @param filter contains two StationInfo and range of dates between arrival and departure
   * @return SheduleItems that satisfy the conditions
   */
  @Transactional(readOnly = true)
  public List<SheduleItemEntity> searchBetweenStations(StationsFilter filter) {
    List<SheduleItemEntity> sheduleItemsList = new ArrayList<SheduleItemEntity>();

    List<StationInfoEntity> stationInfoList = new ArrayList<StationInfoEntity>();
    stationInfoList.add(filter.getStationInfoFrom());
    stationInfoList.add(filter.getStationInfoTo());
    for (SheduleItemEntity sheduleItem : this.sheduleDAO.getByStations(stationInfoList)) {
      StationEntity stationFrom = null;
      StationEntity stationTo = null;
      for (StationEntity station : sheduleItem.getRoute().getStationsList()) {
        if (station.getStationInfo().equals(filter.getStationInfoFrom())) {
          stationFrom = station;
        }
        if (station.getStationInfo().equals(filter.getStationInfoTo())) {
          stationTo = station;
        }
      }

      if ((stationTo != null)
          && (stationFrom != null)
          && (stationTo.getTimeOffset() > stationFrom.getTimeOffset())) {
        GregorianCalendar depDateStationFrom = new GregorianCalendar();
        depDateStationFrom.setTime(sheduleItem.getDepartureDate());
        depDateStationFrom.add(Calendar.MINUTE, stationFrom.getTimeOffset());

        GregorianCalendar depDateStationTo = new GregorianCalendar();
        depDateStationTo.setTime(sheduleItem.getDepartureDate());
        depDateStationTo.add(Calendar.MINUTE, stationTo.getTimeOffset());

        GregorianCalendar fromDate = null;
        boolean isAfterDepDateFrom = false;
        if (filter.getStartDate() != null) {
          fromDate = new GregorianCalendar();
          fromDate.setTime(filter.getStartDate());
          isAfterDepDateFrom = depDateStationFrom.after(fromDate);
        }

        GregorianCalendar toDate = null;
        boolean isBeforeDepDateTo = false;
        if (filter.getEndDate() != null) {
          toDate = new GregorianCalendar();
          toDate.setTime(filter.getEndDate());
          isBeforeDepDateTo = depDateStationTo.before(toDate);
        }

        boolean needAddSheduleItem = false;
        if (fromDate != null && toDate != null && isAfterDepDateFrom && isBeforeDepDateTo) {
          needAddSheduleItem = true;
        } else if (fromDate != null && toDate == null && isAfterDepDateFrom) {
          needAddSheduleItem = true;
        } else if (fromDate == null && toDate != null && isBeforeDepDateTo) {
          needAddSheduleItem = true;
        } else if (fromDate == null && toDate == null) {
          needAddSheduleItem = true;
        }

        if (needAddSheduleItem) {
          try {
            SheduleItemEntity cloneSheduleItem = (SheduleItemEntity) sheduleItem.clone();
            cloneSheduleItem.getRoute().getStationsList().clear();
            cloneSheduleItem.getRoute().getStationsList().add(stationFrom);
            cloneSheduleItem.getRoute().getStationsList().add(stationTo);
            sheduleItemsList.add(cloneSheduleItem);
          } catch (CloneNotSupportedException exc) {
            exc.printStackTrace();
            LOGGER.warn(exc);
          }
        }
      }
    }

    return sheduleItemsList;
  }
  private void readTechnique(Statement techStat) throws IOException {
    isUseNodes = false;
    String[] split = techStat.getLine().split(whitespacePattern);

    String name;
    if (split.length == 1) {
      name = TechniqueDef.DEFAULT_TECHNIQUE_NAME;
    } else if (split.length == 2) {
      name = split[1];
    } else {
      throw new IOException("Technique statement syntax incorrect");
    }

    String techniqueUniqueName = materialDef.getAssetName() + "@" + name;
    technique = new TechniqueDef(name, techniqueUniqueName.hashCode());

    for (Statement statement : techStat.getContents()) {
      readTechniqueStatement(statement);
    }

    technique.setShaderPrologue(createShaderPrologue(presetDefines));

    switch (technique.getLightMode()) {
      case Disable:
        technique.setLogic(new DefaultTechniqueDefLogic(technique));
        break;
      case MultiPass:
        technique.setLogic(new MultiPassLightingLogic(technique));
        break;
      case SinglePass:
        technique.setLogic(new SinglePassLightingLogic(technique));
        break;
      case StaticPass:
        technique.setLogic(new StaticPassLightingLogic(technique));
        break;
      case SinglePassAndImageBased:
        technique.setLogic(new SinglePassAndImageBasedLightingLogic(technique));
        break;
      default:
        throw new UnsupportedOperationException();
    }

    List<TechniqueDef> techniqueDefs = new ArrayList<>();

    if (isUseNodes) {
      nodesLoaderDelegate.computeConditions();

      // used for caching later, the shader here is not a file.

      // KIRILL 9/19/2015
      // Not sure if this is needed anymore, since shader caching
      // is now done by TechniqueDef.
      technique.setShaderFile(
          technique.hashCode() + "", technique.hashCode() + "", "GLSL100", "GLSL100");
      techniqueDefs.add(technique);
    } else if (shaderNames.containsKey(Shader.ShaderType.Vertex)
        && shaderNames.containsKey(Shader.ShaderType.Fragment)) {
      if (shaderLanguages.size() > 1) {
        for (int i = 1; i < shaderLanguages.size(); i++) {
          TechniqueDef td = null;
          try {
            td = (TechniqueDef) technique.clone();
          } catch (CloneNotSupportedException e) {
            e.printStackTrace();
          }
          td.setShaderFile(shaderNames, shaderLanguages.get(i));
          techniqueDefs.add(td);
        }
      }
      technique.setShaderFile(shaderNames, shaderLanguages.get(0));
      techniqueDefs.add(technique);

    } else {
      technique = null;
      shaderLanguages.clear();
      shaderNames.clear();
      presetDefines.clear();
      langSize = 0;
      logger.log(Level.WARNING, "Fixed function technique was ignored");
      logger.log(
          Level.WARNING,
          "Fixed function technique ''{0}'' was ignored for material {1}",
          new Object[] {name, key});
      return;
    }

    for (TechniqueDef techniqueDef : techniqueDefs) {
      materialDef.addTechniqueDef(techniqueDef);
    }

    technique = null;
    langSize = 0;
    shaderLanguages.clear();
    shaderNames.clear();
    presetDefines.clear();
  }
// -------------------------------