001 /* 002 * Copyright 2002 - 2007 JEuclid, http://jeuclid.sf.net 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017 /* $Id: FillRectObject.java,v 8afef6dd0d58 2007/09/14 08:29:58 maxberger $ */ 018 019 package net.sourceforge.jeuclid.layout; 020 021 import java.awt.Color; 022 import java.awt.Graphics2D; 023 import java.awt.geom.Rectangle2D; 024 025 /** 026 * @version $Revision: 8afef6dd0d58 $ 027 */ 028 public class FillRectObject implements GraphicsObject { 029 030 private final Color c; 031 032 private final float a; 033 034 private final float d; 035 036 private final float w; 037 038 /** 039 * Default Constructor. 040 * 041 * @param ascent 042 * Ascent. 043 * @param descent 044 * Descent. 045 * @param width 046 * Width. 047 * @param color 048 * Color. 049 */ 050 public FillRectObject(final Color color, final float ascent, 051 final float descent, final float width) { 052 this.c = color; 053 this.a = ascent; 054 this.d = descent; 055 this.w = width; 056 } 057 058 /** {@inheritDoc} */ 059 public void paint(final float x, final float y, final Graphics2D g) { 060 g.setColor(this.c); 061 g.fill(new Rectangle2D.Float(x, y - this.a, this.w, this.a + this.d)); 062 } 063 }