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; }
/** * 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(); } }
/** * clone a copy of oclOperator * * @throws CloneNotSupportedException * @return Object */ public Object clone() throws CloneNotSupportedException { try { oclEvent op = new oclEvent(); op.opName = (oclPredicate) opName.clone(); ListIterator li = prevail.listIterator(); while (li.hasNext()) { oclSE se = (oclSE) li.next(); op.addPrevSE((oclSE) se.clone()); } li = necessary.listIterator(); while (li.hasNext()) { oclSC sc = (oclSC) li.next(); op.addNecSC((oclSC) sc.clone()); } li = conditional.listIterator(); while (li.hasNext()) { oclSC sc = (oclSC) li.next(); op.addCondSC((oclSC) sc.clone()); } return op; } catch (CloneNotSupportedException e) { Utility.debugPrintln("Failed to clone event component + " + e.toString()); throw e; } }
/** 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()); } }
/** * Use copy() if you want to have a deep copy(), i.e., with all references copied correctly. * * @return shallow copy of this attribute */ public Object clone() { Object o = null; try { o = super.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); // Never occurs } return o; }
/** A check for cloning. */ public void testCloning2() { LineAndShapeRenderer r1 = new LineAndShapeRenderer(); r1.setBasePaint(Color.blue); r1.setBaseLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); LineAndShapeRenderer r2 = null; try { r2 = (LineAndShapeRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); MyRendererChangeListener listener = new MyRendererChangeListener(); r2.addChangeListener(listener); r2.setBasePaint(Color.red); assertTrue(listener.lastEvent.getRenderer() == r2); assertFalse(r1.hasListener(listener)); }
/** Confirm that cloning works. */ public void testCloning() { LineAndShapeRenderer r1 = new LineAndShapeRenderer(); Rectangle2D shape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); Rectangle2D baseShape = new Rectangle2D.Double(11.0, 12.0, 13.0, 14.0); r1.setShape(shape); r1.setBaseShape(baseShape); r1.setBaseLegendShape(new Rectangle(4, 3, 2, 1)); r1.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 3)); r1.setBaseLegendTextPaint(new Color(1, 2, 3)); LineAndShapeRenderer r2 = null; try { r2 = (LineAndShapeRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); r1.setSeriesVisible(0, Boolean.FALSE); assertFalse(r1.equals(r2)); r2.setSeriesVisible(0, Boolean.FALSE); assertTrue(r1.equals(r2)); r1.setSeriesVisibleInLegend(0, Boolean.FALSE); assertFalse(r1.equals(r2)); r2.setSeriesVisibleInLegend(0, Boolean.FALSE); assertTrue(r1.equals(r2)); r1.setSeriesPaint(0, Color.black); assertFalse(r1.equals(r2)); r2.setSeriesPaint(0, Color.black); assertTrue(r1.equals(r2)); r1.setSeriesFillPaint(0, Color.yellow); assertFalse(r1.equals(r2)); r2.setSeriesFillPaint(0, Color.yellow); assertTrue(r1.equals(r2)); r1.setSeriesOutlinePaint(0, Color.yellow); assertFalse(r1.equals(r2)); r2.setSeriesOutlinePaint(0, Color.yellow); assertTrue(r1.equals(r2)); r1.setSeriesStroke(0, new BasicStroke(2.2f)); assertFalse(r1.equals(r2)); r2.setSeriesStroke(0, new BasicStroke(2.2f)); assertTrue(r1.equals(r2)); r1.setSeriesOutlineStroke(0, new BasicStroke(2.2f)); assertFalse(r1.equals(r2)); r2.setSeriesOutlineStroke(0, new BasicStroke(2.2f)); assertTrue(r1.equals(r2)); shape.setRect(4.0, 3.0, 2.0, 1.0); assertFalse(r1.equals(r2)); r2.setShape(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(r1.equals(r2)); baseShape.setRect(4.0, 3.0, 2.0, 1.0); assertFalse(r1.equals(r2)); r2.setBaseShape(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(r1.equals(r2)); r1.setSeriesShape(0, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(r1.equals(r2)); r2.setSeriesShape(0, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(r1.equals(r2)); r1.setSeriesItemLabelsVisible(0, Boolean.TRUE); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelsVisible(0, Boolean.TRUE); assertTrue(r1.equals(r2)); r1.setSeriesItemLabelPaint(0, Color.red); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelPaint(0, Color.red); assertTrue(r1.equals(r2)); r1.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition()); assertFalse(r1.equals(r2)); r2.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition()); assertTrue(r1.equals(r2)); r1.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition()); assertFalse(r1.equals(r2)); r2.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition()); assertTrue(r1.equals(r2)); r1.setSeriesCreateEntities(0, Boolean.FALSE); assertFalse(r1.equals(r2)); r2.setSeriesCreateEntities(0, Boolean.FALSE); assertTrue(r1.equals(r2)); r1.setLegendShape(0, new Rectangle(9, 7, 3, 4)); assertFalse(r1.equals(r2)); r2.setLegendShape(0, new Rectangle(9, 7, 3, 4)); assertTrue(r1.equals(r2)); r1.setBaseLegendShape(new Rectangle(3, 4, 1, 5)); assertFalse(r1.equals(r2)); r2.setBaseLegendShape(new Rectangle(3, 4, 1, 5)); assertTrue(r1.equals(r2)); r1.setLegendTextFont(1, new Font("Dialog", Font.PLAIN, 33)); assertFalse(r1.equals(r2)); r2.setLegendTextFont(1, new Font("Dialog", Font.PLAIN, 33)); assertTrue(r1.equals(r2)); r1.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 11)); assertFalse(r1.equals(r2)); r2.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 11)); assertTrue(r1.equals(r2)); r1.setLegendTextPaint(3, Color.red); assertFalse(r1.equals(r2)); r2.setLegendTextPaint(3, Color.red); assertTrue(r1.equals(r2)); r1.setBaseLegendTextPaint(Color.green); assertFalse(r1.equals(r2)); r2.setBaseLegendTextPaint(Color.green); assertTrue(r1.equals(r2)); }