Java Code Examples for java.awt.Graphics.getClipBounds()

The following are Jave code examples for showing how to use getClipBounds() of the java.awt.Graphics class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Tarski   File: EditorPalette.java   View Source Code Vote up 6 votes
/**
 * 
 */
public void paintComponent(Graphics g)
{
	if (gradientColor == null)
	{
		super.paintComponent(g);
	}
	else
	{
		Rectangle rect = getVisibleRect();

		if (g.getClipBounds() != null)
		{
			rect = rect.intersection(g.getClipBounds());
		}

		Graphics2D g2 = (Graphics2D) g;

		g2.setPaint(new GradientPaint(0, 0, getBackground(), getWidth(), 0,
				gradientColor));
		g2.fill(rect);
	}
}
 
Example 2
Project: OpenJSharp   File: JLayeredPane.java   View Source Code Vote up 6 votes
/**
 * Paints this JLayeredPane within the specified graphics context.
 *
 * @param g  the Graphics context within which to paint
 */
public void paint(Graphics g) {
    if(isOpaque()) {
        Rectangle r = g.getClipBounds();
        Color c = getBackground();
        if(c == null)
            c = Color.lightGray;
        g.setColor(c);
        if (r != null) {
            g.fillRect(r.x, r.y, r.width, r.height);
        }
        else {
            g.fillRect(0, 0, getWidth(), getHeight());
        }
    }
    super.paint(g);
}
 
Example 3
Project: rapidminer   File: SliderUI.java   View Source Code Vote up 6 votes
@Override
public void paint(Graphics g, JComponent c) {
	recalculateIfInsetsChanged();
	recalculateIfOrientationChanged();
	Rectangle clip = g.getClipBounds();

	if (!clip.intersects(trackRect) && slider.getPaintTrack()) {
		calculateGeometry();
	}

	if (slider.getPaintTrack() && clip.intersects(trackRect)) {
		paintTrack(g);
	}
	if (slider.hasFocus() && clip.intersects(focusRect)) {
		paintFocus(g);
	}

	// the ticks are now inside the track so they have to be painted each thumb movement
	paintTicks(g);
	// thumb is always painted due to value below thumb
	paintThumb(g);
}
 
Example 4
Project: rapidminer   File: TreeUI.java   View Source Code Vote up 6 votes
protected void paintHorizontalSeparators(Graphics g, JComponent c) {
	Rectangle clipBounds = g.getClipBounds();

	int beginRow = getRowForPath(this.tree, getClosestPathForLocation(this.tree, 0, clipBounds.y));
	int endRow = getRowForPath(this.tree, getClosestPathForLocation(this.tree, 0, clipBounds.y + clipBounds.height - 1));

	if ((beginRow <= -1) || (endRow <= -1)) {
		return;
	}

	for (int i = beginRow; i <= endRow; ++i) {
		TreePath path = getPathForRow(this.tree, i);

		if ((path != null) && (path.getPathCount() == 2)) {
			Rectangle rowBounds = getPathBounds(this.tree, getPathForRow(this.tree, i));

			// Draw a line at the top
			if (rowBounds != null) {
				g.drawLine(clipBounds.x, rowBounds.y, clipBounds.x + clipBounds.width, rowBounds.y);
			}
		}
	}

}
 
Example 5
Project: TrabalhoFinalEDA2   File: mxUtils.java   View Source Code Vote up 6 votes
/**
 * 
 */
public static void fillClippedRect(Graphics g, int x, int y, int width,
		int height)
{
	Rectangle bg = new Rectangle(x, y, width, height);

	try
	{
		if (g.getClipBounds() != null)
		{
			bg = bg.intersection(g.getClipBounds());
		}
	}
	catch (Exception e)
	{
		// FIXME: Getting clipbounds sometimes throws an NPE
	}

	g.fillRect(bg.x, bg.y, bg.width, bg.height);
}
 
Example 6
Project: incubator-netbeans   File: BaseView.java   View Source Code Vote up 5 votes
/** It divides painting into three areas:
* INSETS_TOP, MAIN_AREA, INSETS_BOTTOM. It paints them sequentially
* using <CODE>paintArea()</CODE> method until it returns false.
* This implementation also supposes that <CODE>allocation</CODE> is
* instance of <CODE>Rectangle</CODE> to save object creations. The root
* view in TextUI implementation will take care to ensure child views will
* get rectangle instances.
*/
public void paint(Graphics g, Shape allocation) {
    Rectangle clip = g.getClipBounds();
    if (clip.height < 0 || clip.width < 0) {
        return;
    }
    int paintAreas = getPaintAreas(g, clip.y, clip.height);
    if (paintAreas != 0) {
        paintAreas(g, clip.y, clip.height, paintAreas);
    }
}
 
Example 7
Project: incubator-netbeans   File: DropdownButton.java   View Source Code Vote up 5 votes
public void paint(Graphics g) {
    Rectangle c = g.getClipBounds();
    if (pushed || !isEnabled() || container.getComponent(0) != this)
        g.setClip(0, 0, getWidth() - POPUP_EXTENT, getHeight());
    super.paint(g);
    g.setClip(c);
}
 
Example 8
Project: incubator-netbeans   File: DropdownButton.java   View Source Code Vote up 5 votes
public void paint(Graphics g) {
    if (pushed || !button.isEnabled() || container.getComponent(0) == this) {
        Rectangle c = g.getClipBounds();
        g.setClip(getWidth() - POPUP_EXTENT, 0, POPUP_EXTENT, getHeight());
        super.paint(g);
        g.setClip(c);
    }
}
 
Example 9
Project: incubator-netbeans   File: ProfilerXYTooltipOverlay.java   View Source Code Vote up 5 votes
public void paint(Graphics g) {
    if (tooltipPainter == null) return;

    Rectangle bounds = new Rectangle(0, 0, getWidth(), getHeight());
    Rectangle clip = g.getClipBounds();
    if (clip == null) g.setClip(bounds);
    else g.setClip(clip.intersection(bounds));

    super.paint(g);
}
 
Example 10
Project: incubator-netbeans   File: FoldingSideBar.java   View Source Code Vote up 5 votes
@Override
public void paintComponent(Graphics g) {
    Rectangle cp = g.getClipBounds();
    g.setColor(getBackground());
    g.fillRect(cp.x, cp.y, cp.width, cp.height);
    if (lines == null) {
        return;
    }
    g.setColor(getForeground());
    FontMetrics fontMetrics = textView.getFontMetrics(textView.getFont());
    int lineHeight = fontMetrics.getHeight();
    int descent = fontMetrics.getDescent();
    int offset = 0;
    try {
        Rectangle modelToView = textView.modelToView(0);
        offset = modelToView == null ? 0 : modelToView.y;
    } catch (BadLocationException ex) {
        LOG.log(Level.INFO, null, ex);
    }
    offset += lineHeight - fontMetrics.getAscent();

    int size = lines.getLineCount();
    int logLine = 0; // logical line (including wrapped lines)
    int nextLogLine;
    int firstVisibleLine = Math.max(0, getLineAtPosition(cp.y) - 1);
    int lastVisibleLine = getLastVisibleLine(cp, size);
    for (int i = firstVisibleLine; i < lastVisibleLine; i++) {
        if (!lines.isVisible(i)) {
            continue;
        }
        nextLogLine = findLogicalLineIndex(findNextVisibleLine(i), size);
        drawLineGraphics(g, i, logLine, nextLogLine, offset, lineHeight,
                descent);
        logLine = nextLogLine;
    }
}
 
Example 11
Project: incubator-netbeans   File: JXTableDecorator.java   View Source Code Vote up 5 votes
/**
 * Paints the backgrounds of the implied empty rows when the
 * table model is insufficient to fill all the visible area
 * available to us. We don't involve cell renderers, because
 * we have no data.
 */
protected void paintEmptyRows(Graphics g) {
    final int rowCount = getRowCount();
    final Rectangle clip = g.getClipBounds();
    final int height = clip.y + clip.height;
    if (rowCount * rowHeight < height) {
        for (int i = rowCount; i <= height / rowHeight; ++i) {
            g.setColor(backgroundColorForRow(i));
            g.fillRect(clip.x, i * rowHeight, clip.width, rowHeight);
            drawHorizontalLine(g, clip, i);
        }
        drawVerticalLines(g, rowCount, height);
    }
}
 
Example 12
Project: Equella   File: JFlatDialog.java   View Source Code Vote up 5 votes
@Override
public void paint(Graphics g)
{
	// Draw the background:
	if( getBackground() != null )
	{
		Rectangle clip = g.getClipBounds();
		g.setColor(getBackground());
		g.fillRect(clip.x, clip.y, clip.width, clip.height);
	}

	// Draw the backing to the text:
	int transX = (int) g.getFontMetrics().getStringBounds(getText(), g).getWidth() + getInsets().left;

	if( TEXT_BACK != null && TEXT_BACK.getWidth(null) > 0 )
	{
		for( int i = 0; i < transX; i += TEXT_BACK.getWidth(null) )
			g.drawImage(TEXT_BACK, i, 0, null);
	}

	// Draw transition:
	if( transition != null )
	{
		g.drawImage(transition, transX, 0, null);
	}

	// Draw the text:
	super.paint(g);
}
 
Example 13
Project: brModelo   File: InspectorExtenderEditor.java   View Source Code Vote up 5 votes
@Override
public void paint(Graphics g) {
    super.paint(g);
    //Color bkp = g.getColor();
    Rectangle r = this.getBounds();
    g.setColor(Color.BLACK);
    int re = 0;
    String bonito = "?";
    if (getAcaoTipo() == TipoDeAcao.tpAcaoDlgCor || getAcaoTipo() == TipoDeAcao.tpReadOnlyCor) {
        g.setColor(Color.BLACK);
        g.fillRect(3, 3, r.height - 7, r.height - 7);
        try {
            Color c = util.Utilidades.StringToColor(getTexto());
            g.setColor(c);
            bonito = getTexto();
        } catch (Exception e) {
        }
        g.fillRect(4, 4, r.height - 8, r.height - 8);
        //g.setColor(Color.BLACK);
        //g.drawRect(3, 3, r.height - 7, r.height - 7);
        re = r.height - 1;
    } else {
        bonito = getTexto().replaceAll("\n", " | ");
    }
    //g.setColor(bkp);
    
    Rectangle obkp = g.getClipBounds();

    g.setColor(Color.DARK_GRAY);
    g.setFont(new Font(this.getFont().getFontName(), Font.BOLD, getFont().getSize()));
    g.clipRect(re, 0, r.width - r.height -re - (re == 0? 4: 8), r.height);
    g.drawString(bonito, re + 2, (int) (r.height * 0.72) + 1);
    g.drawLine(0, 0, 0, getHeight());
    g.setClip(obkp);
}
 
Example 14
Project: Logisim   File: Print.java   View Source Code Vote up 4 votes
@Override
public int print(Graphics base, PageFormat format, int pageIndex) {
	if (pageIndex >= circuits.size())
		return Printable.NO_SUCH_PAGE;

	Circuit circ = circuits.get(pageIndex);
	CircuitState circState = proj.getCircuitState(circ);
	Graphics g = base.create();
	Graphics2D g2 = g instanceof Graphics2D ? (Graphics2D) g : null;
	FontMetrics fm = g.getFontMetrics();
	String head = (header != null && !header.equals(""))
			? format(header, pageIndex + 1, circuits.size(), circ.getName())
			: null;
	int headHeight = (head == null ? 0 : fm.getHeight());

	// Compute image size
	double imWidth = format.getImageableWidth();
	double imHeight = format.getImageableHeight();

	// Correct coordinate system for page, including
	// translation and possible rotation.
	Bounds bds = circ.getBounds(g).expand(4);
	double scale = Math.min(imWidth / bds.getWidth(), (imHeight - headHeight) / bds.getHeight());
	if (g2 != null) {
		g2.translate(format.getImageableX(), format.getImageableY());
		if (rotateToFit && scale < 1.0 / 1.1) {
			double scale2 = Math.min(imHeight / bds.getWidth(), (imWidth - headHeight) / bds.getHeight());
			if (scale2 >= scale * 1.1) { // will rotate
				scale = scale2;
				if (imHeight > imWidth) { // portrait -> landscape
					g2.translate(0, imHeight);
					g2.rotate(-Math.PI / 2);
				} else { // landscape -> portrait
					g2.translate(imWidth, 0);
					g2.rotate(Math.PI / 2);
				}
				double t = imHeight;
				imHeight = imWidth;
				imWidth = t;
			}
		}
	}

	// Draw the header line if appropriate
	if (head != null) {
		g.drawString(head, (int) Math.round((imWidth - fm.stringWidth(head)) / 2), fm.getAscent());
		if (g2 != null) {
			imHeight -= headHeight;
			g2.translate(0, headHeight);
		}
	}

	// Now change coordinate system for circuit, including
	// translation and possible scaling
	if (g2 != null) {
		if (scale < 1.0) {
			g2.scale(scale, scale);
			imWidth /= scale;
			imHeight /= scale;
		}
		double dx = Math.max(0.0, (imWidth - bds.getWidth()) / 2);
		g2.translate(-bds.getX() + dx, -bds.getY());
	}

	// Ensure that the circuit is eligible to be drawn
	Rectangle clip = g.getClipBounds();
	clip.add(bds.getX(), bds.getY());
	clip.add(bds.getX() + bds.getWidth(), bds.getY() + bds.getHeight());
	g.setClip(clip);

	// And finally draw the circuit onto the page
	ComponentDrawContext context = new ComponentDrawContext(proj.getFrame().getCanvas(), circ, circState, base,
			g, printerView);
	Collection<Component> noComps = Collections.emptySet();
	circ.draw(context, noComps);
	g.dispose();
	return Printable.PAGE_EXISTS;
}
 
Example 15
Project: incubator-netbeans   File: DrawEngineLineView.java   View Source Code Vote up 4 votes
public void paint(Graphics g, Shape a) {
    if (!(getDocument() instanceof BaseDocument)) return; //#48134
    // When painting make sure the estimated span is set to false
    setEstimatedSpan(false);
    // No modifications to allocReadOnly variable!
    Rectangle allocReadOnly = (a instanceof Rectangle) ? (Rectangle)a : a.getBounds();
    int startOffset = getStartOffset();
    int endOffset = getAdjustedEOLOffset();
    try{
        if (isFragment()){
            Rectangle oldClipRect = g.getClipBounds();                
            Rectangle newClip = new Rectangle(oldClipRect);
            Rectangle startOffsetClip = modelToView(startOffset, a, Position.Bias.Forward).getBounds();
            Rectangle endOffsetClip = modelToView(endOffset, a, Position.Bias.Forward).getBounds();
            View parent = getParent();
            if (parent instanceof FoldMultiLineView && !equals(parent.getView(parent.getViewCount() - 1))) {
                newClip.width = Math.min(oldClipRect.width, endOffsetClip.x);
                
                if (newClip.width + newClip.x > endOffsetClip.x) {
                    newClip.width = newClip.width - (newClip.width + newClip.x - endOffsetClip.x);
                }
                
                g.setClip(newClip);
            }

            int shift = startOffsetClip.x - getEditorUI().getTextMargin().left - allocReadOnly.x;
            g.translate(-shift,0);
            
            DrawEngine.getDrawEngine().draw(this, new DrawGraphics.GraphicsDG(g),
            getEditorUI(), startOffset, endOffset,
            getBaseX(allocReadOnly.x), allocReadOnly.y, Integer.MAX_VALUE);
            
            g.translate(shift,0);                
            g.setClip(oldClipRect);

        }else{
            JTextComponent component = getComponent();
            if (component!=null){
                long ts1 = 0, ts2 = 0;
                if (loggable) {
                    ts1 = System.currentTimeMillis();
                }
                
                // Translate the graphics clip region to the document offsets
                // and their view region
                Rectangle clip = g.getClipBounds();
                int fromOffset = viewToModel(clip.x, clip.y, allocReadOnly, null);
                int toOffset = viewToModel(clip.x + clip.width, clip.y, allocReadOnly, null);
                
                fromOffset = Math.max(fromOffset - 1, getStartOffset());
                toOffset = Math.min(toOffset + 1, getAdjustedEOLOffset());
                
                Rectangle rr = modelToView(fromOffset, allocReadOnly, Position.Bias.Forward).getBounds();
                
                DrawEngine.getDrawEngine().draw(this, new DrawGraphics.GraphicsDG(g),
                    getEditorUI(), fromOffset, toOffset,
                    rr.x, rr.y, Integer.MAX_VALUE);
                
                if (loggable) {
                    ts2 = System.currentTimeMillis();
                    if (ts2 - ts1 > PERF_TRESHOLD) {
                        LOG.finest("paint: " + //NOI18N
                            "<" + fromOffset + ", " + toOffset + ">, " + //NOI18N
                            "DrawEngine.startX = " + rr.x + ", DrawEngine.startY = " + rr.y + ", " + //NOI18N
                            "shape = [" + allocReadOnly.x + ", " + allocReadOnly.y + ", " + allocReadOnly.width + ", " + allocReadOnly.height + "], " + //NOI18N
                            "clip = [" + clip.x + ", " + clip.y + ", " + clip.width + ", " + clip.height + "] " + //NOI18N
                            "took " + (ts2 - ts1) + " msec"); //NOI18N
                    }
                }
            }
        }
    } catch (BadLocationException ble) {
        LOG.log(Level.INFO, "Painting the view failed", ble); //NOI18N
    }
}
 
Example 16
Project: incubator-netbeans   File: GapBoxViewChildren.java   View Source Code Vote up 4 votes
/**
 * Paint the children that intersect the clip area.
 *
 * @param g graphics to render into.
 * @param alloc allocation for the parent view including the insets.
 *  The rectangle can be mutated.
 */
protected void paintChildren(Graphics g, Rectangle alloc) {
    int viewAllocX = alloc.x;
    int viewAllocY = alloc.y;
    // int viewAllocWidth = alloc.width;
    // int viewAllocHeight = alloc.height;
    
    alloc = g.getClipBounds(alloc); // get the clip - reuse alloc variable
    if (alloc == null) { // no clip => return
        return;
    }
    int clipX = alloc.x;
    int clipY = alloc.y;
    boolean isXMajorAxis = view.isXMajorAxis();
    int clipEnd = isXMajorAxis
        ? (clipX + alloc.width)
        : (clipY + alloc.height);
    

    int childIndex = getChildIndexAtCorePoint(clipX, clipY);
    int childCount = getChildCount();

    for (int i = Math.max(childIndex, 0); i < childCount; i++) {
        ViewLayoutState child = getChild(i);
        // Reuse alloc for child's allocation
        alloc = getChildCoreAllocation(i, alloc);
        alloc.x += viewAllocX;
        alloc.y += viewAllocY;
        /*
         * Paint the child if it lies before the end of the clip.
         * We should also check whether the child
         * fits into the allocation given to this view by checking whether
         *     parentViewAllocation.intersects(childAllocation))
         * but for the orthogonal use this should not be necessary.
         */
        int allocStart = isXMajorAxis ? alloc.x : alloc.y;
                
        if (allocStart < clipEnd) { // child at least partly inside clip
            
            View v = child.getView();
            v.paint(g, alloc);
        } else {
            break; // stop painting of children
        }
    }
}
 
Example 17
Project: incubator-netbeans   File: TaskListTableUI.java   View Source Code Vote up 4 votes
/** Paint a representation of the <code>table</code> instance
    * that was set in installUI().
    * 
    * (copy & paste from BasicTableUI)
    */
   public void paint(Graphics g, JComponent c) {
       Rectangle clip = g.getClipBounds();

       Rectangle bounds = table.getBounds();
       // account for the fact that the graphics has already been translated
       // into the table's bounds
       bounds.x = bounds.y = 0;

if (table.getRowCount() <= 0 || table.getColumnCount() <= 0 ||
               // this check prevents us from painting the entire table
               // when the clip doesn't intersect our bounds at all
               !bounds.intersects(clip)) {

    return;
}

Point upperLeft = clip.getLocation();
Point lowerRight = new Point(clip.x + clip.width - 1, clip.y + clip.height - 1);
       int rMin = table.rowAtPoint(upperLeft);
       int rMax = table.rowAtPoint(lowerRight);
       // This should never happen (as long as our bounds intersect the clip,
       // which is why we bail above if that is the case).
       if (rMin == -1) {
    rMin = 0;
       }
       // If the table does not have enough rows to fill the view we'll get -1.
       // (We could also get -1 if our bounds don't intersect the clip,
       // which is why we bail above if that is the case).
       // Replace this with the index of the last row.
       if (rMax == -1) {
    rMax = table.getRowCount()-1;
       }

       boolean ltr = table.getComponentOrientation().isLeftToRight();
       int cMin = table.columnAtPoint(ltr ? upperLeft : lowerRight); 
       int cMax = table.columnAtPoint(ltr ? lowerRight : upperLeft);        
       // This should never happen.
       if (cMin == -1) {
    cMin = 0;
       }
// If the table does not have enough columns to fill the view we'll get -1.
       // Replace this with the index of the last column.
       if (cMax == -1) {
    cMax = table.getColumnCount()-1;
       }

       // Paint the grid.
       paintGrid(g, rMin, rMax, cMin, cMax);

       // Paint the cells.
paintCells(g, rMin, rMax, cMin, cMax);
   }
 
Example 18
Project: jdk8u-jdk   File: SynthTableUI.java   View Source Code Vote up 4 votes
/**
 * Paints the specified component.
 *
 * @param context context for the component being painted
 * @param g the {@code Graphics} object used for painting
 * @see #update(Graphics,JComponent)
 */
protected void paint(SynthContext context, Graphics g) {
    Rectangle clip = g.getClipBounds();

    Rectangle bounds = table.getBounds();
    // account for the fact that the graphics has already been translated
    // into the table's bounds
    bounds.x = bounds.y = 0;

    if (table.getRowCount() <= 0 || table.getColumnCount() <= 0 ||
            // this check prevents us from painting the entire table
            // when the clip doesn't intersect our bounds at all
            !bounds.intersects(clip)) {

        paintDropLines(context, g);
        return;
    }

    boolean ltr = table.getComponentOrientation().isLeftToRight();

    Point upperLeft = clip.getLocation();

    Point lowerRight = new Point(clip.x + clip.width - 1,
                                 clip.y + clip.height - 1);

    int rMin = table.rowAtPoint(upperLeft);
    int rMax = table.rowAtPoint(lowerRight);
    // This should never happen (as long as our bounds intersect the clip,
    // which is why we bail above if that is the case).
    if (rMin == -1) {
        rMin = 0;
    }
    // If the table does not have enough rows to fill the view we'll get -1.
    // (We could also get -1 if our bounds don't intersect the clip,
    // which is why we bail above if that is the case).
    // Replace this with the index of the last row.
    if (rMax == -1) {
        rMax = table.getRowCount()-1;
    }

    int cMin = table.columnAtPoint(ltr ? upperLeft : lowerRight);
    int cMax = table.columnAtPoint(ltr ? lowerRight : upperLeft);
    // This should never happen.
    if (cMin == -1) {
        cMin = 0;
    }
    // If the table does not have enough columns to fill the view we'll get -1.
    // Replace this with the index of the last column.
    if (cMax == -1) {
        cMax = table.getColumnCount()-1;
    }

    // Paint the cells.
    paintCells(context, g, rMin, rMax, cMin, cMax);

    // Paint the grid.
    // it is important to paint the grid after the cells, otherwise the grid will be overpainted
    // because in Synth cell renderers are likely to be opaque
    paintGrid(context, g, rMin, rMax, cMin, cMax);

    paintDropLines(context, g);
}
 
Example 19
Project: sumo   File: MultiThumbSlider.java   View Source Code Vote up 4 votes
public void paint(Graphics g, JComponent c) {

        Rectangle clip = g.getClipBounds();
        thumbRect = zeroRect;

        super.paint(g, c);

        int thumbNum = additonalUi.getThumbNum();
        Rectangle[] thumbRects = additonalUi.getThumbRects();

        for (int i = thumbNum - 1; 0 <= i; i--) {
            if (clip.intersects(thumbRects[i])) {
                thumbRect = thumbRects[i];

                paintThumb(g);

            }
        }
    }
 
Example 20
Project: BrainControl   File: GraphPanel.java   View Source Code Vote up 4 votes
/**
	 * Painting of the Graph
	 */
	
	@Override
	public void paint(Graphics g) {

		
		//drawing the frame of the Graph
		Rectangle r = g.getClipBounds();
		g.setColor(Color.RED);
		g.drawRect(0, 0, (int)r.getWidth(), (int)r.getHeight());

		
		setBackground(Color.WHITE);
		
		g.setColor(Color.GRAY);
		
		
		final int minTime = Math.max(0, elapsedTime - coordinates.displayedTimeInterval);
//		final int maxTime = Math.max(elapsedTime, coordinates.displayedTimeInterval);
		final int graphWidth = (int)r.getWidth() - 2*offset;
		final int graphHeight = (int)r.getHeight() - 2*offset;
		
		//drawing the x axis
		g.drawLine(offset, (int)r.getHeight() - offset, (int)r.getWidth() - offset, (int)r.getHeight() - offset);
		//drawing the y axis
		g.drawLine(offset, offset, offset, (int)r.getHeight() - offset);
		
		g.setColor(Color.BLACK);
		
		//bold shows which reservoir is active and the name of it is to bold 
		if(reservoir.bold)
		{
			g.setFont(new Font("default", Font.BOLD, 14));
		}
		//draw name of reservoir
		g.drawString(reservoir.getName(), (int)(r.getWidth()/2-offset), offset);
		
		g.setFont(new Font("default", Font.PLAIN, 12));
		
		
		//String beginX = String.valueOf(minTime);
		//String endX = String.valueOf(coordinates.displayedTimeInterval + minTime);
		
		//label of the x axis
//		g.drawString(beginX, offset, (int)r.getHeight() - offset + 15);
//		g.drawString(endX, (int)r.getWidth() - offset,(int)r.getHeight() - offset + 15);
		
		//label of the y axis
		g.drawString("0", offset - 10, (int)r.getHeight() - offset);
		g.drawString("1", offset - 10, offset + 10);


		//drawing the graph: showing all the lines which connect the values that are saved in the list ReservoirCoordinate
		if(coordinates.size() > 1) {
			Iterator<ReservoirGuiCoordinate> it = coordinates.iterator();
			ReservoirGuiCoordinate lastCoordinate = it.next();
			Point lastGuiPoint = getGuiPoint(minTime, graphWidth, graphHeight, lastCoordinate);
			Point nextGuiPoint = null;
			while(it.hasNext()) {
				ReservoirGuiCoordinate nextCoordinate = it.next();
				nextGuiPoint = getGuiPoint(minTime, graphWidth, graphHeight, nextCoordinate);
				g.drawLine(lastGuiPoint.x, lastGuiPoint.y, nextGuiPoint.x, nextGuiPoint.y);
				lastGuiPoint = nextGuiPoint;
			}
		}
	
	}