PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/bundles/plugins-trunk/RubyPlugin/src/org/jedit/ruby/structure/TopLineBorder.java

#
Java | 49 lines | 23 code | 4 blank | 22 comment | 1 complexity | 1d3798fd8423aed3081f813b28d09fbd MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /*
  2. * TopLineBorder.java -
  3. *
  4. * Copyright 2005 Robert McKinnon
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. */
  20. package org.jedit.ruby.structure;
  21. import javax.swing.border.LineBorder;
  22. import java.awt.Color;
  23. import java.awt.Component;
  24. import java.awt.Graphics;
  25. /**
  26. * @author robmckinnon at users.sourceforge.net
  27. */
  28. final class TopLineBorder extends LineBorder {
  29. public TopLineBorder() {
  30. super(Color.GRAY);
  31. }
  32. public final void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  33. Color oldColor = g.getColor();
  34. int i;
  35. g.setColor(lineColor);
  36. for (i = 0; i < thickness; i++) {
  37. int newWidth = width - i - i - 1;
  38. int x1 = x + i;
  39. int y1 = y + i;
  40. int x2 = x1 + newWidth;
  41. g.drawLine(x1, y1, x2, y1);
  42. }
  43. g.setColor(oldColor);
  44. }
  45. }