return;
}
final Iterable<PipePart> parts = new TreeSet<>( this.colorParts );
final TextureLoader loader = GraphicsEnv.getInstance().getTextureLoader();
final Segment pipeSegment = this.getSegment();
final Dimension textureDimension;
int gamePosition;
final int upperLimit;
/*
Stampa le texure su schermo.
Game position mantiene la posizione matematica della tubatura (model), e andrà dall'ascissa dell'estremo
più a sinistra se la tubatura è orizzontale oppure dall'ordinata dell'estremo superiore se verticale.
Upperlimit è impostato al limite opposto.
Viene prima dipinta la parte non colorata, poi la parte colorata.
screenPosition mantiene la posizione che deve avere la texture su schermo.
screenPosition viene aggiornato a ogni pezzo di texture come un cursore.
Questa parte riguarda il disegno delle sole parti non modificate in questo step.
*/
Rectangle screenRect;
Point screenPosition;
final Iterator<Map.Entry<Integer, Boolean>> changedIterator = this.changedParts.entrySet()
.iterator();
Map.Entry<Integer, Boolean> nextSkip = changedIterator.hasNext() ? changedIterator.next() : null;
if ( this.isVertical() ) {
textureDimension = loader.getDimension( NON_COLORED_PART_VERTICAL );
gamePosition = pipeSegment.getMinY();
upperLimit = pipeSegment.getMaxY();
for (final PipePart part : parts) {
for (; gamePosition <= upperLimit && gamePosition < part.getStart(); gamePosition++) {
screenRect = GraphicsEnv.getInstance().gamePointAndTextureToScreen( new Point( pipeSegment.getXA(), gamePosition ), textureDimension );
screenPosition = new Point( screenRect.x, screenRect.y );
final String pickTexture;
if ( nextSkip != null && nextSkip.getKey() == gamePosition ) {
pickTexture = ( nextSkip.getValue() ) ? COLORED_PART_VERTICAL : NON_COLORED_PART_VERTICAL;
nextSkip = changedIterator.hasNext() ? changedIterator.next() : null;
} else {
pickTexture = NON_COLORED_PART_VERTICAL;
}
this.doDraw( g2, pickTexture, screenPosition );
}
for (; gamePosition <= part.getEnd(); gamePosition++) {
screenRect = GraphicsEnv.getInstance().gamePointAndTextureToScreen( new Point( pipeSegment.getXA(), gamePosition ), textureDimension );
screenPosition = new Point( screenRect.x, screenRect.y );
final String pickTexture;
if ( nextSkip != null && nextSkip.getKey() == gamePosition ) {
pickTexture = ( nextSkip.getValue() ) ? COLORED_PART_VERTICAL : NON_COLORED_PART_VERTICAL;
nextSkip = changedIterator.hasNext() ? changedIterator.next() : null;
} else {
pickTexture = COLORED_PART_VERTICAL;
}
this.doDraw( g2, pickTexture, screenPosition );
}
}
for (; gamePosition <= upperLimit; gamePosition++) {
screenRect = GraphicsEnv.getInstance().gamePointAndTextureToScreen( new Point( pipeSegment.getXA(), gamePosition ), textureDimension );
screenPosition = new Point( screenRect.x, screenRect.y );
final String pickTexture;
if ( nextSkip != null && nextSkip.getKey() == gamePosition ) {
pickTexture = ( nextSkip.getValue() ) ? COLORED_PART_VERTICAL : NON_COLORED_PART_VERTICAL;
nextSkip = changedIterator.hasNext() ? changedIterator.next() : null;
} else {
pickTexture = NON_COLORED_PART_VERTICAL;
}
this.doDraw( g2, pickTexture, screenPosition );
}
} else {
textureDimension = loader.getDimension( NON_COLORED_PART_HORIZONTAL );
gamePosition = pipeSegment.getMinX();
upperLimit = pipeSegment.getMaxX();
for (final PipePart part : parts) {
for (; gamePosition <= upperLimit && gamePosition < part.getStart(); gamePosition++) {
screenRect = GraphicsEnv.getInstance().gamePointAndTextureToScreen( new Point( gamePosition, pipeSegment.getYA() ), textureDimension );
screenPosition = new Point( screenRect.x, screenRect.y );
final String pickTexture;
if ( nextSkip != null && nextSkip.getKey() == gamePosition ) {
pickTexture = ( nextSkip.getValue() ) ? COLORED_PART_HORIZONTAL : NON_COLORED_PART_HORIZONTAL;
nextSkip = changedIterator.hasNext() ? changedIterator.next() : null;
} else {
pickTexture = NON_COLORED_PART_HORIZONTAL;
}
this.doDraw( g2, pickTexture, screenPosition );
}
for (; gamePosition <= part.getEnd(); gamePosition++) {
screenRect = GraphicsEnv.getInstance().gamePointAndTextureToScreen( new Point( gamePosition, pipeSegment.getYA() ), textureDimension );
screenPosition = new Point( screenRect.x, screenRect.y );
final String pickTexture;
if ( nextSkip != null && nextSkip.getKey() == gamePosition ) {
pickTexture = ( nextSkip.getValue() ) ? COLORED_PART_HORIZONTAL : NON_COLORED_PART_HORIZONTAL;
nextSkip = changedIterator.hasNext() ? changedIterator.next() : null;
} else {
pickTexture = COLORED_PART_HORIZONTAL;
}
this.doDraw( g2, pickTexture, screenPosition );
}
}
for (; gamePosition <= upperLimit; gamePosition++) {
screenRect = GraphicsEnv.getInstance().gamePointAndTextureToScreen( new Point( gamePosition, pipeSegment.getYA() ), textureDimension );
screenPosition = new Point( screenRect.x, screenRect.y );
final String pickTexture;
if ( nextSkip != null && nextSkip.getKey() == gamePosition ) {
pickTexture = ( nextSkip.getValue() ) ? COLORED_PART_HORIZONTAL : NON_COLORED_PART_HORIZONTAL;