balloontip/0000755000175000017500000000000011107552752013722 5ustar handschuhhandschuhballoontip/src/0000755000175000017500000000000011056002150014472 5ustar handschuhhandschuhballoontip/src/net/0000755000175000017500000000000011056002150015260 5ustar handschuhhandschuhballoontip/src/net/java/0000755000175000017500000000000011056002150016201 5ustar handschuhhandschuhballoontip/src/net/java/balloontip/0000755000175000017500000000000011065466050020361 5ustar handschuhhandschuhballoontip/src/net/java/balloontip/TablecellBalloonTip.java0000644000175000017500000001242011107127024025066 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip; import javax.swing.JComponent; import javax.swing.JTable; import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorListener; import javax.swing.event.ChangeEvent; import javax.swing.event.ListSelectionEvent; import javax.swing.event.TableColumnModelEvent; import javax.swing.event.TableColumnModelListener; import net.java.balloontip.positioners.BalloonTipPositioner; import net.java.balloontip.styles.BalloonTipStyle; /** * Provides the same functionality as a BalloonTip, but can attach itself to a specific JTable's cell. * @author Tim Molderez */ public class TablecellBalloonTip extends CustomBalloonTip { private int row; private int column; // If someone messes with the table's columns, this will probably screw up the balloon tip's position, so we'll just close it private TableColumnModelListener columnListener = new TableColumnModelListener() { public void columnAdded(TableColumnModelEvent e) {closeBalloon();} public void columnMarginChanged(ChangeEvent e) {setCellPosition(row, column);} public void columnMoved(TableColumnModelEvent e) {closeBalloon();} public void columnRemoved(TableColumnModelEvent e) {closeBalloon();} public void columnSelectionChanged(ListSelectionEvent e) {} }; // This class is needed when the table hasn't been set up yet during the constructor of this balloon tip private class ConstructorHelper implements AncestorListener { public void ancestorAdded(AncestorEvent event) { ((JTable)attachedComponent).getColumnModel().addColumnModelListener(columnListener); // Don't forget to reposition yourself! During the constructor the table wasn't set up yet, so you couldn't determine the table cell's position then... setCellPosition(row, column); // Remove yourself ((JTable)attachedComponent).removeAncestorListener(this); } public void ancestorMoved(AncestorEvent event) {} public void ancestorRemoved(AncestorEvent event) {} }; /** * @see net.java.balloontip.BalloonTip#BalloonTip(JComponent, String, BalloonTipStyle, Orientation, AttachLocation, int, int, boolean) * @param table The table to attach the balloon tip to * @param row Which row is the balloon tip attached to * @param column Which column is the balloon tip attached to */ public TablecellBalloonTip(JTable table, String text, int row, int column, BalloonTipStyle style, Orientation alignment, AttachLocation attachLocation, int horizontalOffset, int verticalOffset, boolean useCloseButton) { super(table, text, ((JTable)table).getCellRect(row, column, true), style, alignment, attachLocation, horizontalOffset, verticalOffset, useCloseButton); this.row = row; this.column = column; // We can only add the columnListener if we're sure the table has already been properly set up (which is the case if our super-constructor was able to determine the top level container...) if (getTopLevelContainer() != null) { table.getColumnModel().addColumnModelListener(columnListener); } else { table.addAncestorListener(new ConstructorHelper()); } } /** * @see net.java.balloontip.BalloonTip#BalloonTip(JComponent, String, BalloonTipStyle, BalloonTipPositioner, boolean) * @param table The table to attach the balloon tip to * @param row Which row is the balloon tip attached to * @param column Which column is the balloon tip attached to */ public TablecellBalloonTip(JTable table, String text, int row, int column, BalloonTipStyle style, BalloonTipPositioner positioner, boolean useCloseButton) { super(table, text, ((JTable)table).getCellRect(row, column, true), style, positioner, useCloseButton); this.row = row; this.column = column; // We can only add the columnListener if we're sure the table has already been properly set up (which is the case if our super-constructor was able to determine the top level container...) if (getTopLevelContainer() != null) { table.getColumnModel().addColumnModelListener(columnListener); } else { table.addAncestorListener(new ConstructorHelper()); } } /** * Sets the table cell the balloon tip should attach to * @param row * @param column */ public void setCellPosition(int row, int column) { offset = ((JTable)attachedComponent).getCellRect(row, column, true); refreshLocation(); } public void closeBalloon() { super.closeBalloon(); ((JTable)attachedComponent).getColumnModel().removeColumnModelListener(columnListener); } }balloontip/src/net/java/balloontip/images/0000755000175000017500000000000011056002150021611 5ustar handschuhhandschuhballoontip/src/net/java/balloontip/images/close_rollover.png0000644000175000017500000000075710665256272025406 0ustar handschuhhandschuhPNG  IHDRatIME /?a pHYs oygAMA a~IDATxڝSKn@ }N.ZHXr`M% mU8 RU ?g$@K'3#xȢ)@?jRh_]5I/ kRȶ Vyq2I B-4@<5Xp^6 l26Su, n",mfSUF rYmZ3Y|G h8V7 Рp@g4wƼ"JD0f& !r*B`7}.G `6SW&. gj:S &mWUtfX(]Fmy\, ^}@ ).W"˯~g;rIENDB`balloontip/src/net/java/balloontip/images/close_default.png0000644000175000017500000000100610655313572025146 0ustar handschuhhandschuhPNG  IHDRabKGD pHYs B(xtIME =IDAT8˝R1?<@07`x4t4ԡO 3{&}S.LDϫbkȺH+|Z|}l>U->h*z/K(K*Hk׃~`ЂkqQ@Yb$kPoPjYE9O]^E!`EKo8(ZD41rEǴ13z]in#;=?(bFo 9mp|w#8֞oYJڷ׀x;9fic i % WW(Mqh!,-jHB4KXk_ZI !:Tsón&L:5nl66~i/wUIENDB`balloontip/src/net/java/balloontip/images/close_pressed.png0000644000175000017500000000077310655716212025177 0ustar handschuhhandschuhPNG  IHDRatIME @vp pHYs oygAMA aIDATxڝSn0}vH(].H +Dg{V #VP;0 $!>N0Lӝg[ .wB~A;-xL&o`Z \TL*&WROu$FYؙaDQJ@hJtB(ijaVMS %iAy8XEBMڟ=P-iδlf I轫Jڇ"d XfO6 H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-gAMA|Q cHRMz%u0`:o_F`IDATxA 0 ; -QzB`' lPˌV)Jꖚ|xd)_В3=HAP{?}ˆt'F̏o7j 0IUIENDB`balloontip/src/net/java/balloontip/images/bgpattern.png0000644000175000017500000000032210747065644024331 0ustar handschuhhandschuhPNG  IHDR +tEXtCreation Timezo 27 jan 2008 11:47:46 +0100VWtIME 0o pHYsiTSgAMA a*IDATxcz⫞ 09BY B W pC$,IENDB`balloontip/src/net/java/balloontip/styles/0000755000175000017500000000000011063245346021705 5ustar handschuhhandschuhballoontip/src/net/java/balloontip/styles/TexturedBalloonStyle.java0000644000175000017500000001042111107126604026674 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.styles; import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; import java.awt.TexturePaint; import java.awt.image.BufferedImage; import net.java.balloontip.utils.FlipUtils; import net.java.balloontip.utils.ImageUtils; /** * A simple rounded rectangle balloon tip, which can have an image as background * @author Bernhard Pauler * @author Tim Molderez */ public class TexturedBalloonStyle extends BalloonTipStyle { private int arcWidth; private int arcHeight; private BufferedImage bg; private Rectangle bgBounds; private Color borderColor; /** * Constructor * @param arcWidth width of the rounded corner * @param arcHeight height of the rounded color * @param background the background image that's used (it's used as a pattern, so the image will repeat...) * @param borderColor line color */ public TexturedBalloonStyle(int arcWidth, int arcHeight, Image background, Color borderColor) { this.arcWidth = arcWidth; this.arcHeight = arcHeight; this.bg = ImageUtils.toBufferedImage(background); bgBounds = new Rectangle(0,0, bg.getWidth(), bg.getHeight()); this.borderColor = borderColor; } public Insets getBorderInsets(Component c) { if (flipY) { return new Insets(verticalOffset+arcHeight, arcWidth, arcHeight, arcWidth); } else { return new Insets(arcHeight, arcWidth, arcHeight+verticalOffset, arcWidth); } } public boolean isBorderOpaque() { return true; } public void paintBorder(Component c, Graphics g, int x, int y, int bWidth, int bHeight) { Graphics2D g2d = (Graphics2D) g; int rectY = y; if (flipY) { rectY = y + verticalOffset; } g2d.setPaint(new TexturePaint(bg, bgBounds)); g2d.fillRoundRect(x, rectY, bWidth, bHeight-verticalOffset, arcWidth*2, arcHeight*2); g2d.setColor(borderColor); g2d.drawRoundRect(x, rectY, bWidth-1, bHeight-verticalOffset-1, arcWidth*2, arcHeight*2); int[] triangleX = {x+horizontalOffset, x+horizontalOffset+verticalOffset, x+horizontalOffset}; int[] triangleY = {y+bHeight-verticalOffset-1, y+bHeight-verticalOffset-1, y+bHeight-1}; if (flipY) { int flipAxis = bHeight-1; for (int i = 0; i < triangleX.length; i++) { Point flippedPoint = FlipUtils.flipHorizontally(triangleX[i], triangleY[i], flipAxis); triangleX[i] = flippedPoint.x; triangleY[i] = flippedPoint.y; } } if (flipX) { int flipAxis = bWidth-1; for (int i = 0; i < triangleX.length; i++) { Point flippedPoint = FlipUtils.flipVertically(triangleX[i], triangleY[i], flipAxis); triangleX[i] = flippedPoint.x; triangleY[i] = flippedPoint.y; } } g2d.setPaint(new TexturePaint(bg, bgBounds)); g2d.fillPolygon(triangleX, triangleY, 3); g2d.setColor(borderColor); g2d.drawLine(triangleX[0], triangleY[0], triangleX[2], triangleY[2]); g2d.drawLine(triangleX[1], triangleY[1], triangleX[2], triangleY[2]); // Bug workaround, Java Bug Database ID 6644471 g2d.setPaint(new TexturePaint(bg, bgBounds)); g2d.fillPolygon(triangleX, triangleY, 3); g2d.setColor(borderColor); g2d.drawLine(triangleX[0], triangleY[0], triangleX[2], triangleY[2]); g2d.drawLine(triangleX[1], triangleY[1], triangleX[2], triangleY[2]); } public int getMinimalHorizontalOffset() { return arcWidth + verticalOffset; } } balloontip/src/net/java/balloontip/styles/RoundedBalloonStyle.java0000644000175000017500000000724311107126576026510 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.styles; import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.Insets; import java.awt.Point; import net.java.balloontip.utils.FlipUtils; /** * A simple rounded rectangle balloon tip * @author Bernhard Pauler */ public class RoundedBalloonStyle extends BalloonTipStyle { private int arcWidth; private int arcHeight; private Color fillColor; private Color borderColor; /** * Constructor * @param arcWidth width of the rounded corner * @param arcHeight height of the rounded color * @param fillColor fill color * @param borderColor border line color */ public RoundedBalloonStyle(int arcWidth, int arcHeight, Color fillColor, Color borderColor) { this.arcWidth = arcWidth; this.arcHeight = arcHeight; this.fillColor = fillColor; this.borderColor = borderColor; } public Insets getBorderInsets(Component c) { if (flipY) { return new Insets(verticalOffset+arcHeight, arcWidth, arcHeight, arcWidth); } else { return new Insets(arcHeight, arcWidth, arcHeight+verticalOffset, arcWidth); } } public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { int rectY = y; if (flipY) { rectY = y + verticalOffset; } g.setColor(fillColor); g.fillRoundRect(x, rectY, width, height-verticalOffset, arcWidth*2, arcHeight*2); g.setColor(borderColor); g.drawRoundRect(x, rectY, width-1, height-verticalOffset-1, arcWidth*2, arcHeight*2); int[] triangleX = {x+horizontalOffset, x+horizontalOffset+verticalOffset, x+horizontalOffset}; int[] triangleY = {y+height-verticalOffset-1, y+height-verticalOffset-1, y+height-1}; if (flipY) { int flipAxis = height-1; for (int i = 0; i < triangleX.length; i++) { Point flippedPoint = FlipUtils.flipHorizontally(triangleX[i], triangleY[i], flipAxis); triangleX[i] = flippedPoint.x; triangleY[i] = flippedPoint.y; } } if (flipX) { int flipAxis = width-1; for (int i = 0; i < triangleX.length; i++) { Point flippedPoint = FlipUtils.flipVertically(triangleX[i], triangleY[i], flipAxis); triangleX[i] = flippedPoint.x; triangleY[i] = flippedPoint.y; } } g.setColor(fillColor); g.fillPolygon(triangleX, triangleY, 3); g.setColor(borderColor); g.drawLine(triangleX[0], triangleY[0], triangleX[2], triangleY[2]); g.drawLine(triangleX[1], triangleY[1], triangleX[2], triangleY[2]); // Bug workaround, Java Bug Database ID 6644471 g.setColor(fillColor); g.drawLine(triangleX[0], triangleY[0], triangleX[1], triangleY[1]); g.setColor(borderColor); g.drawLine(triangleX[0], triangleY[0], triangleX[0], triangleY[0]); g.drawLine(triangleX[1], triangleY[1], triangleX[1], triangleY[1]); } public int getMinimalHorizontalOffset() { return arcWidth + verticalOffset; } } balloontip/src/net/java/balloontip/styles/ModernBalloonStyle.java0000644000175000017500000001464411107126570026331 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.styles; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Component; import java.awt.GradientPaint; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; import java.awt.RenderingHints; import java.awt.Stroke; import java.awt.geom.GeneralPath; /** * A balloon tip with a vertical linear gradient background * You can also choose which corners should be rounded corners or just plain corners * @author Bernhard Pauler */ public class ModernBalloonStyle extends BalloonTipStyle { private int arcWidth; private int arcHeight; private boolean topLeft = true; private boolean topRight = false; boolean bottomLeft = false; boolean bottomRight = true; private int borderThickness = 1; private boolean AAenabled = false; private Color topFillColor; private Color bottomFillColor; private Color borderColor; /** * Constructor * @param arcWidth width of the rounded corner * @param arcHeight height of the rounded color * @param borderColor line color * @param topFillColor top color of the lineair gradient fill color * @param bottomFillColor bottom color of the lineair gradient fill color */ public ModernBalloonStyle(int arcWidth, int arcHeight, Color topFillColor, Color bottomFillColor, Color borderColor) { this.arcWidth = arcWidth; this.arcHeight = arcHeight; this.topFillColor = topFillColor; this.bottomFillColor = bottomFillColor; this.borderColor = borderColor; } /** * Sets the style for each corner. * If true, this corner will be rounded; if false, it's just a regular corner * @param topLeft * @param topRight * @param bottomLeft * @param bottomRight */ public void setCornerStyles(boolean topLeft, boolean topRight, boolean bottomLeft, boolean bottomRight) { this.topLeft = topLeft; this.topRight = topRight; this.bottomLeft = bottomLeft; this.bottomRight = bottomRight; } /** * Set the thickness of the balloon tip's border, in px * @param thickness */ public void setBorderThickness(int thickness) { borderThickness = thickness; } /** * Enable/disable anti-aliasing for this balloon tip * @param enable if true, AA is enabled; if false, the settings remain untouched */ public void enableAntiAliasing(boolean enable) { AAenabled = enable; } public Insets getBorderInsets(Component c) { if (flipY) { return new Insets(verticalOffset+arcHeight, arcWidth, arcHeight, arcWidth); } else { return new Insets(arcHeight, arcWidth, arcHeight+verticalOffset, arcWidth); } } public boolean isBorderOpaque() { return true; } public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Graphics2D g2d = (Graphics2D) g; if (AAenabled) { g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } // Make room for the border line x+=borderThickness - 1; y+=borderThickness - 1; width-=borderThickness*2; height-=borderThickness*2; int yTop; // Y-coordinate of the top side of the balloon int yBottom; // Y-coordinate of the bottom side of the balloon if (flipY) { yTop = y + verticalOffset; yBottom = y + height; } else { yTop = y; yBottom = y + height - verticalOffset; } // Draw the outline of the balloon GeneralPath outline = new GeneralPath(); outline.moveTo(x + arcWidth, yTop); if (topLeft) { outline.quadTo(x, yTop, x, yTop + arcHeight); } else { outline.lineTo(x, yTop); outline.lineTo(x, yTop + arcHeight); } outline.lineTo(x, yBottom - arcHeight); if (bottomLeft) { outline.quadTo(x, yBottom, x + arcWidth, yBottom); } else { outline.lineTo(x, yBottom); outline.lineTo(x + arcWidth, yBottom); } if (!flipX && !flipY) { outline.lineTo(x + horizontalOffset, yBottom); outline.lineTo(x + horizontalOffset, yBottom + verticalOffset); outline.lineTo(x + horizontalOffset + verticalOffset, yBottom); } else if (flipX && !flipY) { outline.lineTo(x + width - horizontalOffset - verticalOffset, yBottom); outline.lineTo(x + width - horizontalOffset, yBottom + verticalOffset); outline.lineTo(x + width - horizontalOffset, yBottom); } outline.lineTo(x + width - arcWidth, yBottom); if (bottomRight) { outline.quadTo(x + width, yBottom, x + width, yBottom - arcHeight); } else { outline.lineTo(x + width, yBottom); outline.lineTo(x + width, yBottom - arcHeight); } outline.lineTo(x + width, yTop + arcHeight); if (topRight) { outline.quadTo(x + width, yTop, x + width - arcWidth, yTop); } else { outline.lineTo(x + width, yTop); outline.lineTo(x + width - arcWidth, yTop); } if (!flipX && flipY) { outline.lineTo(x + horizontalOffset + verticalOffset, yTop); outline.lineTo(x + horizontalOffset, yTop - verticalOffset); outline.lineTo(x + horizontalOffset, yTop); } else if (flipX && flipY) { outline.lineTo(x + width - horizontalOffset, yTop); outline.lineTo(x + width - horizontalOffset, yTop - verticalOffset); outline.lineTo(x + width - horizontalOffset - verticalOffset, yTop); } outline.closePath(); // Now paint the sucker :) g2d.setPaint(new GradientPaint(0, yTop,topFillColor, 0, yBottom, bottomFillColor)); g2d.fill(outline); g2d.setPaint(borderColor); Stroke backup = g2d.getStroke(); g2d.setStroke(new BasicStroke(borderThickness)); g2d.draw(outline); g2d.setStroke(backup); } public int getMinimalHorizontalOffset() { return arcWidth + verticalOffset + borderThickness; } } balloontip/src/net/java/balloontip/styles/MinimalBalloonStyle.java0000644000175000017500000001026111107126564026465 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.styles; import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; import java.awt.RenderingHints; import java.awt.geom.GeneralPath; /** * A minimal anti-aliased balloon tip style with no border, also supports a transparent fill color * @author Bernhard Pauler */ public class MinimalBalloonStyle extends BalloonTipStyle { private int arcWidth; private Color fillColor; /** * Constructor * @param fillColor fill color (transparent colors are allowed) * @param arcWidth the radius of a rounded corner */ public MinimalBalloonStyle(Color fillColor, int arcWidth) { this.fillColor = fillColor; this.arcWidth = arcWidth; } public Insets getBorderInsets(Component c) { if (flipY) { return new Insets(verticalOffset+arcWidth, arcWidth, arcWidth, arcWidth); } else { return new Insets(arcWidth, arcWidth, arcWidth+verticalOffset, arcWidth); } } public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int yTop; // Y-coordinate of the top side of the balloon int yBottom; // Y-coordinate of the bottom side of the balloon if (flipY) { yTop = y + verticalOffset; yBottom = y + height; } else { yTop = y; yBottom = y + height - verticalOffset; } // Draw the outline of the balloon GeneralPath outline = new GeneralPath(); outline.moveTo(x + arcWidth, yTop); // Top left corner outline.quadTo(x, yTop, x, yTop + arcWidth); // Left side outline.lineTo(x, yBottom - arcWidth); // Bottom left corner outline.quadTo(x, yBottom, x + arcWidth, yBottom); // Bottom side if (!flipX && !flipY) { outline.lineTo(x + horizontalOffset - verticalOffset, yBottom); outline.lineTo(x + horizontalOffset, yBottom + verticalOffset); outline.lineTo(x + horizontalOffset + verticalOffset, yBottom); } else if (flipX && !flipY) { outline.lineTo(x + width - horizontalOffset - verticalOffset, yBottom); outline.lineTo(x + width - horizontalOffset, yBottom + verticalOffset); outline.lineTo(x + width - horizontalOffset + verticalOffset, yBottom); } outline.lineTo(x + width - arcWidth, yBottom); // Bottom right corner outline.quadTo(x + width, yBottom, x + width, yBottom - arcWidth); // Right side outline.lineTo(x + width, yTop + arcWidth); // Top right corner outline.quadTo(x + width, yTop, x + width - arcWidth, yTop); // Top side if (!flipX && flipY) { outline.lineTo(x + horizontalOffset + verticalOffset, yTop); outline.lineTo(x + horizontalOffset, yTop - verticalOffset); outline.lineTo(x + horizontalOffset - verticalOffset, yTop); } else if (flipX && flipY) { outline.lineTo(x + width - horizontalOffset + verticalOffset, yTop); outline.lineTo(x + width - horizontalOffset, yTop - verticalOffset); outline.lineTo(x + width - horizontalOffset - verticalOffset, yTop); } outline.closePath(); // Now paint the sucker :) g2d.setPaint(fillColor); g2d.fill(outline); } public int getMinimalHorizontalOffset() { return arcWidth + verticalOffset; } public boolean isBorderOpaque() { return fillColor.getAlpha()==255; } } balloontip/src/net/java/balloontip/styles/EdgedBalloonStyle.java0000644000175000017500000000633311107126560026110 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.styles; import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.Insets; import java.awt.Point; import net.java.balloontip.utils.FlipUtils; /** * A simple edged balloon tip style * @author Bernhard Pauler */ public class EdgedBalloonStyle extends BalloonTipStyle { private Color borderColor; private Color fillColor; /** * Constructor * @param borderColor border line color * @param fillColor fill color */ public EdgedBalloonStyle(Color fillColor, Color borderColor) { this.borderColor = borderColor; this.fillColor = fillColor; } public Insets getBorderInsets(Component c) { if (flipY) { return new Insets(verticalOffset + 1, 1, 1, 1); } else { return new Insets(1, 1, verticalOffset + 1 , 1); } } public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { int rectY = y; if (flipY) { rectY = y + verticalOffset; } g.setColor(fillColor); g.fillRect(x, rectY, width, height-verticalOffset); g.setColor(borderColor); g.drawRect(x, rectY, width-1, height-verticalOffset-1); int[] triangleX = {x+horizontalOffset, x+horizontalOffset+verticalOffset, x+horizontalOffset}; int[] triangleY = {y+height-verticalOffset-1, y+height-verticalOffset-1, y+height-1}; if (flipY) { int flipAxis = height-1; for (int i = 0; i < triangleX.length; i++) { Point flippedPoint = FlipUtils.flipHorizontally(triangleX[i], triangleY[i], flipAxis); triangleX[i] = flippedPoint.x; triangleY[i] = flippedPoint.y; } } if (flipX) { int flipAxis = width-1; for (int i = 0; i < triangleX.length; i++) { Point flippedPoint = FlipUtils.flipVertically(triangleX[i], triangleY[i], flipAxis); triangleX[i] = flippedPoint.x; triangleY[i] = flippedPoint.y; } } g.setColor(fillColor); g.fillPolygon(triangleX, triangleY, 3); g.setColor(borderColor); g.drawLine(triangleX[0], triangleY[0], triangleX[2], triangleY[2]); g.drawLine(triangleX[1], triangleY[1], triangleX[2], triangleY[2]); // Bug workaround, Java Bug Database ID 6644471 g.setColor(fillColor); g.drawLine(triangleX[0], triangleY[0], triangleX[1], triangleY[1]); g.setColor(borderColor); g.drawLine(triangleX[0], triangleY[0], triangleX[0], triangleY[0]); g.drawLine(triangleX[1], triangleY[1], triangleX[1], triangleY[1]); } } balloontip/src/net/java/balloontip/styles/BalloonTipStyle.java0000644000175000017500000000522711107126552025636 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.styles; import java.awt.Component; import java.awt.Insets; import javax.swing.border.Border; /** * Implement this interface to create a BalloonTip style * @author Tim Molderez */ public abstract class BalloonTipStyle implements Border { protected int horizontalOffset = 0; protected int verticalOffset = 0; protected boolean flipX = false; protected boolean flipY = false; /** * Sets a new value for the horizontal offset. * @param px horizontal offset (in pixels) */ public void setHorizontalOffset(int px) { horizontalOffset = px; } /** * Sets a new value for the vertical offset. * @param px horizontal offset (in pixels) */ public void setVerticalOffset(int px) { verticalOffset = px; } /** * Get the minimum value of the horizontal offset * (Also useful as a maximum; maximum horizontaloffset = balloon tip width - minimum horizontal offset) * @return Minimul horizontal offset */ public int getMinimalHorizontalOffset() { return verticalOffset; } /** * Flip around a vertical axis * @param flipX */ public void flipX(boolean flipX) { this.flipX = flipX; } /** * Flip around a horizontal axis * @param flipY */ public void flipY(boolean flipY) { this.flipY = flipY; } /** * Which mirror effect should be applied to the balloon tip * @param flipX * @param flipY */ public void flip(boolean flipX, boolean flipY) { this.flipX = flipX; this.flipY = flipY; } /** * Is this balloon tip opaque? * @return True if opaque, false if the border uses transparency */ public boolean isBorderOpaque() { return true; } /** * Retrieve the balloon tip's border insets * @return The balloon tip's border insets */ public abstract Insets getBorderInsets(Component c); } balloontip/src/net/java/balloontip/BalloonTip.java0000644000175000017500000004545311107127012023267 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip; import java.awt.Color; import java.awt.Container; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JLayeredPane; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.RootPaneContainer; import javax.swing.SwingUtilities; import javax.swing.border.EmptyBorder; import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorListener; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import net.java.balloontip.positioners.BalloonTipPositioner; import net.java.balloontip.positioners.BasicBalloonTipPositioner; import net.java.balloontip.positioners.Left_Above_Positioner; import net.java.balloontip.positioners.Left_Below_Positioner; import net.java.balloontip.positioners.Right_Above_Positioner; import net.java.balloontip.positioners.Right_Below_Positioner; import net.java.balloontip.styles.BalloonTipStyle; import net.java.balloontip.styles.RoundedBalloonStyle; /** * A balloon tip which can be attached to about any JComponent * @author Bernhard Pauler */ public class BalloonTip extends JPanel { /** * Should the balloon be placed above, below, right or left of the attached component? */ public enum Orientation {LEFT_ABOVE, RIGHT_ABOVE, LEFT_BELOW, RIGHT_BELOW}; /** * Where should the balloon's tip be located, relative to the attached component * ALIGNED makes sure the balloon's edge is aligned with the attached component */ public enum AttachLocation {ALIGNED, CENTER, NORTH, NORTHEAST, EAST, SOUTHEAST, SOUTH, SOUTHWEST, WEST, NORTHWEST}; private static Icon defaultIcon = new ImageIcon(BalloonTip.class.getResource("/net/java/balloontip/images/close_default.png")); private static Icon rolloverIcon = new ImageIcon(BalloonTip.class.getResource("/net/java/balloontip/images/close_rollover.png")); private static Icon pressedIcon = new ImageIcon(BalloonTip.class.getResource("/net/java/balloontip/images/close_pressed.png")); private JLabel label = new JLabel(); private JButton closeButton = null; private boolean isVisible = true; private boolean clickToClose = false; private boolean clickToHide = false; private ComponentAdapter attachedComponentListener = new ComponentAdapter() { public void componentMoved(ComponentEvent e) {refreshLocation();} public void componentResized(ComponentEvent e) {refreshLocation();} public void componentShown(ComponentEvent e) {checkVisibility();} public void componentHidden(ComponentEvent e) {checkVisibility();} }; private ComponentAdapter topLevelContainerListener = new ComponentAdapter() { public void componentResized(ComponentEvent e) { if (attachedComponent.isShowing()) { refreshLocation(); } } }; private MouseAdapter clickListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) {e.consume();} public void mouseReleased(MouseEvent e) { if (clickToHide) { setVisible(false); } else if (clickToClose) { closeBalloon(); } } }; private AncestorListener attachedComponentParentListener = null; protected BalloonTipStyle style; // Determines the balloon's looks protected BalloonTipPositioner positioner; // Determines the balloon's position protected JLayeredPane topLevelContainer = null; // The balloon is drawn on this pane protected JComponent attachedComponent; // The balloon is attached to this component /** * Constructor * A simple constructor, the balloon tip will get a default look * @param attachedComponent Attach the balloon tip to this component * @param text The contents of the balloon tip (may contain HTML) */ public BalloonTip(JComponent attachedComponent, String text) { this(attachedComponent, text, new RoundedBalloonStyle(5,5,Color.WHITE, Color.BLACK), true); } /** * Constructor * @param attachedComponent Attach the balloon tip to this component * @param text The contents of the balloon tip (may contain HTML) * @param style The balloon tip's looks * @param useCloseButton If true, the balloon tip gets a close button */ public BalloonTip(JComponent attachedComponent, String text, BalloonTipStyle style, boolean useCloseButton) { this(attachedComponent, text, style, Orientation.LEFT_ABOVE, AttachLocation.ALIGNED, 16, 20, useCloseButton); } /** * Constructor * @param attachedComponent Attach the balloon tip to this componen * @param text The contents of the balloon tip (may contain HTML) * @param style The balloon tip's looks * @param orientation Orientation of the balloon tip * @param attachLocation Location of the balloon's tip within the attached component * @param horizontalOffset Horizontal offset for the balloon's tip * @param verticalOffset Vertical offset for the balloon's tip * @param useCloseButton If true, the balloon tip gets a close button */ public BalloonTip(JComponent attachedComponent, String text, BalloonTipStyle style, Orientation orientation, AttachLocation attachLocation, int horizontalOffset, int verticalOffset, boolean useCloseButton) { // Setup the appropriate positioner BasicBalloonTipPositioner positioner = null; float attachX = 0.0f; float attachY = 0.0f; boolean fixedAttachLocation = true; switch (attachLocation) { case ALIGNED: fixedAttachLocation = false; break; case CENTER: attachX = 0.5f; attachY = 0.5f; break; case NORTH: attachX = 0.5f; break; case NORTHEAST: attachX = 1.0f; break; case EAST: attachX = 1.0f; attachY = 0.5f; break; case SOUTHEAST: attachX = 1.0f; attachY = 1.0f; break; case SOUTH: attachX = 0.5f; attachY = 1.0f; break; case SOUTHWEST: attachY = 1.0f; break; case WEST: attachY = 0.5f; break; case NORTHWEST: break; } switch (orientation) { case LEFT_ABOVE: positioner = new Left_Above_Positioner(horizontalOffset, verticalOffset); break; case LEFT_BELOW: positioner = new Left_Below_Positioner(horizontalOffset, verticalOffset); break; case RIGHT_ABOVE: positioner = new Right_Above_Positioner(horizontalOffset, verticalOffset); break; case RIGHT_BELOW: positioner = new Right_Below_Positioner(horizontalOffset, verticalOffset); break; } positioner.enableFixedAttachLocation(fixedAttachLocation); positioner.setAttachLocation(attachX, attachY); initializePhase1(attachedComponent, text, style, positioner, useCloseButton); } /** * Constructor * @param attachedComponent Attach the balloon tip to this component * @param text The contents of the balloon tip (may contain HTML) * @param style The balloon tip's looks * @param positioner Determines the way the balloon tip is positioned * @param useCloseButton If true, the balloon tip gets a close button */ public BalloonTip(JComponent attachedComponent, String text, BalloonTipStyle style, BalloonTipPositioner positioner, boolean useCloseButton) { initializePhase1(attachedComponent, text, style, positioner, useCloseButton); } public void finalize() { closeBalloon(); // This will remove all of the listeners a balloon tip uses... } /** * Set the text message that should appear in the balloon tip. * HTML formatting is supported. * @param text */ public void setText(String text) { label.setText(text); refreshLocation(); } /** * Get the text message that appears in the balloon tip. * @return The text shown in the balloon tip */ public String getText() { return label.getText(); } /** * Set the icon that should appear at the left side of the balloon tip * @param icon The icon (If it has a null-value, the balloon will not have an icon...) */ public void setIcon(Icon icon) { label.setIcon(icon); refreshLocation(); } /** * Get the icon that appears at the left side of the balloon tip * (Returns null if there is no such icon) * @return The balloon tip's icon */ public Icon getIcon() { return label.getIcon(); } /** * Sets the distance (in px) between the icon and the text label * @param iconTextGap */ public void setIconTextGap(int iconTextGap) { label.setIconTextGap(iconTextGap); refreshLocation(); } /** * Get the distance (in px) between the icon and the text label * @return The distance between the balloon tip's icon and its text */ public int getIconTextGap() { return label.getIconTextGap(); } /** * Set the balloon tip's style * @param style */ public void setStyle(BalloonTipStyle style) { // Notify property listeners that the style has changed firePropertyChange("style", this.style, style); this.style = style; setBorder(this.style); refreshLocation(); } /** * Get the balloon tip's style * @return The balloon tip's style */ public BalloonTipStyle getStyle() { return style; } /** * Set a new BalloonTipPositioner * @param positioner */ public void setPositioner(BalloonTipPositioner positioner) { // Notify property listeners that the positioner has changed firePropertyChange("positioner", this.positioner, positioner); this.positioner = positioner; this.positioner.setBalloonTip(this); refreshLocation(); } /** * Retrieve the BalloonTipPositioner that is used by this BalloonTip * @return The balloon tip's positioner */ public BalloonTipPositioner getPositioner() { return positioner; } /** * Set the amount of padding in this balloon tip * @param padding */ public void setPadding(int padding) { label.setBorder(new EmptyBorder(padding, padding, padding, padding)); refreshLocation(); } /** * Get the amount of padding in this balloon tip * @return The amount of padding in the balloon tip */ public int getPadding() { return label.getBorder().getBorderInsets(this).left; } /** * Hide the balloon tip just by clicking anywhere on it * @param enabled if true, the balloon hides when it's clicked */ public void enableClickToHide(boolean enabled) { clickToHide = enabled; } /** * Permanently close the balloon tip just by clicking anywhere on it * @param enabled if true, the balloon permanently closes when it's clicked */ public void enableClickToClose(boolean enabled) { clickToClose = enabled; } /** * If you want to permanently close the balloon, use this method. * (If you just need to hide the balloon, use setVisible(false);) * You cannot use this BalloonTip-instance anymore after calling this method! */ public void closeBalloon() { setVisible(false); attachedComponent.removeComponentListener(attachedComponentListener); if (topLevelContainer != null) { topLevelContainer.remove(this); topLevelContainer.removeComponentListener(attachedComponentListener); } removeMouseListener(clickListener); } /** * Set the close-button icons for all balloon tips * @param normal * @param pressed * @param rollover If you don't want a rollover, just set this to null... */ public static void setCloseButtonIcons(Icon normal, Icon pressed, Icon rollover) { defaultIcon = normal; rolloverIcon = rollover; pressedIcon = pressed; } /** * Sets the border of the balloon tip's close button. * If no close button is used, nothing will happen. * @param top * @param left * @param bottom * @param right */ public void setCloseButtonBorder(int top, int left, int bottom, int right) { if (closeButton != null) { closeButton.setBorder(BorderFactory.createEmptyBorder(top, left, bottom, right)); refreshLocation(); } } /** * Replace the close button's behaviour * (The default behaviour is to permanently close the balloon...) * with your own action listener * @param act */ public void setCloseButtonActionListener(ActionListener act) { // We assume there's one listener present... ActionListener[] listeners = closeButton.getActionListeners(); closeButton.removeActionListener(listeners[0]); closeButton.addActionListener(act); } /** * Retrieve the component this balloon tip is attached to * @return The attached component */ public JComponent getAttachedComponent() { return attachedComponent; } /** * Retrieve the container this balloon tip is drawn on * If the balloon tip hasn't determined this container yet, null is returned * @return The balloon tip's top level container */ public JLayeredPane getTopLevelContainer() { return topLevelContainer; } /** * Redetermines and sets the balloon tip's location */ public void refreshLocation() { Point location = SwingUtilities.convertPoint(attachedComponent, getLocation(), this); try { positioner.determineAndSetLocation(new Rectangle(location.x, location.y, attachedComponent.getWidth(), attachedComponent.getHeight())); } catch (NullPointerException exc) {} } public void setVisible(boolean visible) { isVisible = visible; super.setVisible(visible); } /* * Shows the balloon if the attached component is visible; hides the balloon if the attached component is invisible... */ private void checkVisibility() { // If we can see the attached component, the balloon tip is not closed AND we want it to be visible, then show it... if (attachedComponent.isShowing() && isVisible) { refreshLocation(); super.setVisible(true); } else { super.setVisible(false); } } /* * Helper method for constructing a BalloonTip */ private void initializePhase1(final JComponent attachedComponent, String text, BalloonTipStyle style, BalloonTipPositioner positioner, boolean useCloseButton) { this.attachedComponent = attachedComponent; this.style = style; this.positioner = positioner; setBorder(this.style); setOpaque(false); setLayout(new GridBagLayout()); label.setBorder(new EmptyBorder(5, 5, 5, 5)); label.setText(text); add(label, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); if (useCloseButton) { closeButton = new JButton(); closeButton.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 5)); closeButton.setContentAreaFilled(false); closeButton.setIcon(defaultIcon); closeButton.setRolloverIcon(rolloverIcon); closeButton.setPressedIcon(pressedIcon); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeBalloon(); } }); add(closeButton, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } // Attempt to run initializePhase2() ... try { initializePhase2(); } catch (NullPointerException exc) { /* If we failed to determine the top level container, it's because attachedComponent.getParent() returned null... * We'll just have to wait until the parent is set and try again... */ attachedComponentParentListener = new AncestorListener() { public void ancestorAdded(AncestorEvent event) { initializePhase2(); // Remove yourself attachedComponent.removeAncestorListener(attachedComponentParentListener); refreshLocation(); repaint(); } public void ancestorMoved(AncestorEvent event) {} public void ancestorRemoved(AncestorEvent event) {} }; attachedComponent.addAncestorListener(attachedComponentParentListener); } } /* * Helper method for constructing a BalloonTip; when this method finishes, the balloon tip is ready for use * * The main task here is to attempt to determine the top level container, which is where the balloon tip is drawn. * (This is done by following the path of parent Components, starting at the attached component...) */ private void initializePhase2() { Container parent = attachedComponent.getParent(); // Follow the path of parents of the attached component until you find the top level container while (true) { // If you're a top level container (JFrame, JDialog, JInternalFrame, JApplet or JWindow) if (parent instanceof RootPaneContainer) { topLevelContainer = ((RootPaneContainer)parent).getLayeredPane(); // Exit the infinite loop break; // If you're a tab } else if (parent instanceof JTabbedPane) { /* Due to a bug in JTabbedPane, switching tabs does not cause component events * that tell which components are now visible / invisible. * This piece of code is a workaround. We'll check our attached component's visibility by listening to the JTabbedPane... */ ((JTabbedPane)parent).addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { checkVisibility(); } }); } parent = parent.getParent(); } // We use the popup layer of the top level container (frame or dialog) to show the balloon tip topLevelContainer.add(this, JLayeredPane.POPUP_LAYER); // If the attached component is moved/hidden/shown, the balloon tip should act accordingly attachedComponent.addComponentListener(attachedComponentListener); // If the window is resized, we should check if the balloon still fits topLevelContainer.addComponentListener(topLevelContainerListener); // Don't allow to click 'through' the component; will also enable to close the balloon when it's clicked addMouseListener(clickListener); // Finally pass the balloon tip to its positioner this.positioner.setBalloonTip(this); refreshLocation(); } }balloontip/src/net/java/balloontip/CustomBalloonTip.java0000644000175000017500000001360011107127016024453 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import javax.swing.JComponent; import javax.swing.JViewport; import javax.swing.SwingUtilities; import net.java.balloontip.positioners.BalloonTipPositioner; import net.java.balloontip.styles.BalloonTipStyle; /** * Provides the same functionality as a BalloonTip, but you can add a certain offset, * which can come in handy if attached to custom components. * Also, if the attached component is part of a JScrollPane, the balloon tip can be set such that it will * only be visible if the chosen offset point is visible. * @author Tim Molderez */ public class CustomBalloonTip extends BalloonTip { // A rectangular shape within the custom component; the balloon tip will attach to this rectangle protected Rectangle offset = new Rectangle(0,0,1,1); // If the custom component is located in a viewport, we'll need it to determine when the balloon tip should hide itself private JViewport viewport = null; // If the viewport changes, so should the balloon tip private ComponentAdapter viewportListenerListener = new ComponentAdapter() { public void componentMoved(ComponentEvent e) { if (attachedComponent.isShowing()) { refreshLocation(); } } public void componentResized(ComponentEvent e) { if (attachedComponent.isShowing()) { refreshLocation(); } } }; /** * @see net.java.balloontip.BalloonTip#BalloonTip(JComponent, String, BalloonTipStyle, Orientation, AttachLocation, int, int, boolean) * @param attachedComponent The custom component to attach the balloon tip to * @param offset Specifies a rectangle within the attached component; the balloon tip will attach to this rectangle. * Do note that the coordinates should be relative to the attached component's top left corner. */ public CustomBalloonTip(JComponent attachedComponent, String text, Rectangle offset, BalloonTipStyle style, Orientation alignment, AttachLocation attachLocation, int horizontalOffset, int verticalOffset, boolean useCloseButton) { super(attachedComponent, text, style, alignment, attachLocation, horizontalOffset, verticalOffset, useCloseButton); this.offset = offset; refreshLocation(); } /** * @see net.java.balloontip.BalloonTip#BalloonTip(JComponent, String, BalloonTipStyle, BalloonTipPositioner, boolean) * @param attachedComponent The custom component to attach the balloon tip to * @param offset Specifies a rectangle within the attached component; the balloon tip will attach to this rectangle. * Do note that the coordinates should be relative to the attached component's top left corner. */ public CustomBalloonTip(JComponent attachedComponent, String text, Rectangle offset, BalloonTipStyle style, BalloonTipPositioner positioner, boolean useCloseButton) { super(attachedComponent, text, style, positioner, useCloseButton); this.offset = offset; refreshLocation(); } /** * Set the offset within the attached component * @param offset */ public void setOffset(Rectangle offset) { this.offset = offset; refreshLocation(); } public void closeBalloon() { if (viewport != null) { viewport.removeComponentListener(viewportListenerListener); } super.closeBalloon(); } /** * Sets up the balloon tip such that it will only be shown if * the table cell we're attached to is visible within this viewport. * This is very useful if, for example, the JTable with this balloon tip is inside a JScrollpane. * (You can also remove the viewport by calling setViewport(null).) * @param viewport */ public void setViewport(JViewport viewport) { this.viewport = viewport; viewport.addComponentListener(viewportListenerListener); } /** * Retrieve the viewport that this balloon tip is monitoring, such that the balloon tip will hide itself * once the balloon's tip is outside of this viewport. * @return The viewport this balloon tip is located in */ public JViewport getViewport() { return viewport; } public void refreshLocation() { Point location = SwingUtilities.convertPoint(attachedComponent, getLocation(), this); try { positioner.determineAndSetLocation(new Rectangle(location.x + offset.x, location.y + offset.y, offset.width, offset.height)); if (viewport != null) { // Determine whether the point that visually connects the balloon and the table cell still is visible... Rectangle view = new Rectangle(SwingUtilities.convertPoint(viewport, viewport.getLocation(), getTopLevelContainer()), viewport.getSize()); Point tipLocation = positioner.getTipLocation(); if (tipLocation.y >= view.y-1 // -1 because we still want to allow balloons that are attached to the very top... && tipLocation.y <= (view.y + view.height) && (tipLocation.x) >= view.x && (tipLocation.x) <= (view.x + view.width)) { setVisible(true); } else { setVisible(false); } } } catch (NullPointerException exc) {} } }balloontip/src/net/java/balloontip/examples/0000755000175000017500000000000011073470322022173 5ustar handschuhhandschuhballoontip/src/net/java/balloontip/examples/applet/0000755000175000017500000000000011073512770023464 5ustar handschuhhandschuhballoontip/src/net/java/balloontip/examples/applet/AppletExample.java0000644000175000017500000000557311107126300027066 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.examples.applet; import java.awt.Color; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JApplet; import javax.swing.JButton; import javax.swing.JPanel; import net.java.balloontip.BalloonTip; import net.java.balloontip.styles.EdgedBalloonStyle; /** * Simple application demonstrating a BalloonTip in a JApplet * @author Tim Molderez */ public class AppletExample extends JApplet { public void init() { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { // Setup the content pane JPanel contentPane = new JPanel(); contentPane.setLayout(new GridBagLayout()); setContentPane(contentPane); // Add a button final JButton button = new JButton("Show balloon tip"); button.setSelected(true); contentPane.add(button, new GridBagConstraints(0,0,1,1,1,1, GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets(0,0,60,120), 0, 0)); /*** Balloon tip creation - START ***/ // Create the look for our balloon tip EdgedBalloonStyle style = new EdgedBalloonStyle(Color.WHITE, Color.BLUE); // Now construct the balloon tip final BalloonTip balloonTip = new BalloonTip( button, "This balloon tip is attached to the button.", style, BalloonTip.Orientation.LEFT_ABOVE, BalloonTip.AttachLocation.ALIGNED, 30, 10, true ); // Don't close the balloon when clicking the close-button, you just need to hide it balloonTip.setCloseButtonActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { balloonTip.setVisible(false); } }); /*** Balloon tip creation - END ***/ button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { balloonTip.setVisible(true); } }); } }); } } balloontip/src/net/java/balloontip/examples/simple/0000755000175000017500000000000011056002150023453 5ustar handschuhhandschuhballoontip/src/net/java/balloontip/examples/simple/SimpleExample.java0000644000175000017500000000660411107126370027101 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.examples.simple; import java.awt.Color; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import net.java.balloontip.BalloonTip; import net.java.balloontip.styles.EdgedBalloonStyle; /** * Simple application demonstrating a BalloonTip * @author Tim Molderez */ public class SimpleExample { /** * Main method * @param args command-line arguments (unused) */ public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { // Setup the application's window JFrame frame = new JFrame("Simple BalloonTip example"); frame.setIconImage(new ImageIcon(SimpleExample.class.getResource("/net/java/balloontip/images/frameicon.png")).getImage()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Setup the content pane JPanel contentPane = new JPanel(); contentPane.setLayout(new GridBagLayout()); frame.setContentPane(contentPane); // Add a button final JButton button = new JButton("Show balloon tip"); button.setSelected(true); contentPane.add(button, new GridBagConstraints(0,0,1,1,1,1, GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets(0,0,60,120), 0, 0)); /*** Balloon tip creation - START ***/ // Create the look for our balloon tip EdgedBalloonStyle style = new EdgedBalloonStyle(Color.WHITE, Color.BLUE); // Now construct the balloon tip final BalloonTip balloonTip = new BalloonTip( button, "This balloon tip is attached to the button.", style, BalloonTip.Orientation.LEFT_ABOVE, BalloonTip.AttachLocation.ALIGNED, 30, 10, true ); // Don't close the balloon when clicking the close-button, you just need to hide it balloonTip.setCloseButtonActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { balloonTip.setVisible(false); } }); /*** Balloon tip creation - END ***/ button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { balloonTip.setVisible(true); } }); frame.pack(); frame.setSize(320, 240); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } } balloontip/src/net/java/balloontip/examples/positioner/0000755000175000017500000000000011063333704024367 5ustar handschuhhandschuhballoontip/src/net/java/balloontip/examples/positioner/SimpleTipPositioner.java0000644000175000017500000000342011107126362031212 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.examples.positioner; import java.awt.Point; import java.awt.Rectangle; import net.java.balloontip.BalloonTip; import net.java.balloontip.positioners.BalloonTipPositioner; /** * A sample implementation of a BalloonTipPositioner * @author Tim Molderez */ public class SimpleTipPositioner extends BalloonTipPositioner { int x = 0; // Current position of the balloon tip int y = 0; public void setBalloonTip(BalloonTip bT) { super.setBalloonTip(bT); bT.getStyle().setHorizontalOffset(20); bT.getStyle().setVerticalOffset(20); } public void determineAndSetLocation(Rectangle attached) { x = attached.x; y = attached.y - balloonTip.getPreferredSize().height; balloonTip.setBounds(x, y, balloonTip.getPreferredSize().width, balloonTip.getPreferredSize().height); balloonTip.revalidate(); } public Point getTipLocation() { return new Point(x + 20, y + balloonTip.getPreferredSize().height); } }balloontip/src/net/java/balloontip/examples/positioner/SimplePositionerExample.java0000644000175000017500000000641111107126356032057 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.examples.positioner; import java.awt.Color; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import net.java.balloontip.BalloonTip; import net.java.balloontip.styles.EdgedBalloonStyle; /** * Simple application demonstrating a BalloonTip with a custom BalloonTipPositioner * @author Tim Molderez */ public class SimplePositionerExample { /** * Main method * @param args command-line arguments (unused) */ public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { // Setup the application's window JFrame frame = new JFrame("Simple BalloonTipPositioner example"); frame.setIconImage(new ImageIcon(SimplePositionerExample.class.getResource("/net/java/balloontip/images/frameicon.png")).getImage()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setSize(320, 240); frame.setLocationRelativeTo(null); // Setup the content pane JPanel contentPane = new JPanel(); contentPane.setLayout(new GridBagLayout()); frame.setContentPane(contentPane); // Add a button final JButton button = new JButton("A button"); button.setSelected(true); contentPane.add(button, new GridBagConstraints(0,0,1,1,1,1, GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets(0,0,60,200), 0, 0)); // Create the look for our balloon tip EdgedBalloonStyle style = new EdgedBalloonStyle(Color.WHITE, Color.BLUE); // Now construct the balloon tip, with our own positioner final BalloonTip balloonTip = new BalloonTip( button, "A balloon tip with a custom positioner", style, new SimpleTipPositioner(), true ); // Don't close the balloon when clicking the close-button, you just need to hide it balloonTip.setCloseButtonActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { balloonTip.setVisible(false); } }); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { balloonTip.setVisible(true); } }); frame.setVisible(true); } }); } } balloontip/src/net/java/balloontip/examples/table/0000755000175000017500000000000011062340602023255 5ustar handschuhhandschuhballoontip/src/net/java/balloontip/examples/table/TableExample.java0000644000175000017500000000656611107126376026512 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.examples.table; import java.awt.Color; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.table.TableColumn; import net.java.balloontip.BalloonTip; import net.java.balloontip.TablecellBalloonTip; import net.java.balloontip.styles.MinimalBalloonStyle; /** * Simple application demonstrating a TablecellBalloonTip * @author Tim Molderez */ public class TableExample { private static TablecellBalloonTip tableBalloon = null; /** * Main method * @param args command-line arguments (unused) */ public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { // Setup the application's window JFrame frame = new JFrame("TablecellBalloonTip example"); frame.setIconImage(new ImageIcon(TableExample.class.getResource("/net/java/balloontip/images/frameicon.png")).getImage()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Setup the content pane JPanel contentPane = new JPanel(); contentPane.setLayout(new GridBagLayout()); frame.setContentPane(contentPane); // Create a table final JTable table = new JTable(32,32); table.getModel().setValueAt("A cell", 16, 16); table.setTableHeader(null); // Remove the table header table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); TableColumn column = null; for (int i=0; i<32; ++i) { column = table.getColumnModel().getColumn(i); column.setPreferredWidth(100); } final JScrollPane tableScrollPane = new JScrollPane(table); tableScrollPane.getHorizontalScrollBar().setUnitIncrement(3); contentPane.add(tableScrollPane, new GridBagConstraints(0,0,1,1,1.0,1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0, 0)); table.scrollRectToVisible(table.getCellRect(8, 16, true)); // Create the TableCellBalloonTip tableBalloon = new TablecellBalloonTip(table, "A TablecellBalloonTip", 16, 16, new MinimalBalloonStyle(new Color(255, 0, 0, 180), 10), BalloonTip.Orientation.LEFT_ABOVE, BalloonTip.AttachLocation.ALIGNED, 40, 20, false); tableBalloon.setViewport(tableScrollPane.getViewport()); frame.pack(); frame.setSize(640, 260); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } } balloontip/src/net/java/balloontip/examples/complete/0000755000175000017500000000000011056002150023772 5ustar handschuhhandschuhballoontip/src/net/java/balloontip/examples/complete/panels/0000755000175000017500000000000011063507156025272 5ustar handschuhhandschuhballoontip/src/net/java/balloontip/examples/complete/panels/UtilitiesTab.java0000644000175000017500000001202711107126346030536 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.examples.complete.panels; import java.awt.Color; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import net.java.balloontip.BalloonTip; import net.java.balloontip.examples.complete.CompleteExample; import net.java.balloontip.styles.EdgedBalloonStyle; import net.java.balloontip.utils.TimingUtils; import net.java.balloontip.utils.ToolTipUtils; public class UtilitiesTab extends JPanel { private BalloonTip tooltipBalloon; /** * Default constructor */ public UtilitiesTab() { setLayout(new GridBagLayout()); int gridY = 0; /* * Draw the GUI */ // Timed balloon tip JPanel timePanel = new JPanel(); timePanel.setLayout(new GridBagLayout()); timePanel.add(new JLabel("Any BalloonTip can be given a time-out value."), new GridBagConstraints(0,0,3,1,1.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10,10,10,0), 0, 0)); timePanel.add(new JLabel("Time-out (ms):"), new GridBagConstraints(0,1,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10,10,10,0), 0, 0)); final JTextField timeout = new JTextField("3000"); timeout.setPreferredSize(new Dimension(50,25)); timePanel.add(timeout, new GridBagConstraints(1,1,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10,10,10,0), 0, 0)); final JButton showBalloon = new JButton("Start timer"); timePanel.add(showBalloon, new GridBagConstraints(2,1,1,1,1.0,1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10,10,10,0), 0, 0)); timePanel.setBorder(BorderFactory.createTitledBorder("Timed balloon tip:")); add(timePanel, new GridBagConstraints(0,gridY,1,1,1.0,1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10,10,10,10), 0, 0)); ++gridY; // Balloon tooltip JPanel tooltipPanel = new JPanel(); tooltipPanel.setLayout(new GridBagLayout()); tooltipPanel.add(new JLabel("Any BalloonTip can be turned into a tooltip"), new GridBagConstraints(0,0,3,1,1.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10,10,10,0), 0, 0)); final JLabel tooltipLabel = new JLabel("Hover me to show the tooltip!"); tooltipLabel.setBorder(BorderFactory.createBevelBorder(1)); JPanel labelPanel = new JPanel(new GridBagLayout()); labelPanel.add(tooltipLabel, new GridBagConstraints(0,0,1,1,1.0,1.0, GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(10,10,10,10), 0, 0)); tooltipPanel.add(labelPanel, new GridBagConstraints(2,1,1,1,1.0,1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10,10,10,0), 0, 0)); tooltipPanel.setBorder(BorderFactory.createTitledBorder("Balloon tooltip:")); add(tooltipPanel, new GridBagConstraints(0,gridY,1,1,1.0,1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10,10,10,10), 0, 0)); ++gridY; /* * Add the GUI's behaviour */ // Timed balloon tip showBalloon.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { int timeoutVal = Integer.parseInt(timeout.getText()); BalloonTip balloonTip = new BalloonTip(showBalloon, "I will dissapear in " + timeoutVal/1000 + " seconds.", new EdgedBalloonStyle(Color.WHITE, Color.BLUE), BalloonTip.Orientation.LEFT_ABOVE, BalloonTip.AttachLocation.ALIGNED, 20, 20, false); TimingUtils.showTimedBalloon(balloonTip, timeoutVal); } catch (Exception exc) { if (!timeout.getText().equals("")) { CompleteExample.showErrorMessage(timeout, "Please enter a positive amount of milliseconds"); } } } }); // Balloon tooltip tooltipBalloon = new BalloonTip(tooltipLabel, "I'm a balloon tooltip!", new EdgedBalloonStyle(Color.WHITE, Color.BLUE), BalloonTip.Orientation.LEFT_ABOVE, BalloonTip.AttachLocation.ALIGNED, 20, 20, false); ToolTipUtils.balloonToToolTip(tooltipBalloon, 500, 3000); } } balloontip/src/net/java/balloontip/examples/complete/panels/LooksTab.java0000644000175000017500000003442411107126326027655 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.examples.complete.panels; import java.awt.Color; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JColorChooser; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import net.java.balloontip.BalloonTip; import net.java.balloontip.examples.complete.CompleteExample; import net.java.balloontip.positioners.BasicBalloonTipPositioner; import net.java.balloontip.styles.EdgedBalloonStyle; import net.java.balloontip.styles.MinimalBalloonStyle; import net.java.balloontip.styles.ModernBalloonStyle; import net.java.balloontip.styles.RoundedBalloonStyle; import net.java.balloontip.styles.TexturedBalloonStyle; public class LooksTab extends JPanel { private BalloonTip balloonTip = null; private JComboBox stylePicker = null; private Color fillColor = Color.WHITE; private JButton fillColorButton = null; private Color borderColor = Color.BLUE; private JButton borderColorButton = null; /** * Default constructor */ public LooksTab() { setLayout(new GridBagLayout()); int gridY = 0; /* * Draw the GUI */ // Description label add(new JLabel("Toy around with these settings to change the balloon tip's looks."), new GridBagConstraints(0,gridY,2,1,1.0,0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10,10,25,0), 0, 0)); ++gridY; // Contents textbox add(new JLabel("Contents:"), new GridBagConstraints(0,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,10,0,0), 0, 0)); final JTextField contents = new JTextField("I'm a balloon tip"); CompleteExample.setToolTip(contents, "The contents of a balloon tip may contain HTML formatting"); contents.setPreferredSize(new Dimension(250,25)); add(contents, new GridBagConstraints(1,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2,10,2,0), 0, 0)); ++gridY; // Styles combobox add(new JLabel("Style:"), new GridBagConstraints(0,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,10,0,0), 0, 0)); String[] stylesOptions = {"Edged", "Rounded", "Modern", "Minimal", "Textured"}; stylePicker = new JComboBox(stylesOptions); add(stylePicker, new GridBagConstraints(1,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2,10,2,0), 0, 0)); ++gridY; // Fill color add(new JLabel("Fill color:"), new GridBagConstraints(0,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2,10,2,0), 0, 0)); fillColorButton = new JButton(); fillColorButton.setBackground(fillColor); fillColorButton.setPreferredSize(new Dimension(35,25)); add(fillColorButton, new GridBagConstraints(1,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2,10,2,0), 0, 0)); ++gridY; // Border color add(new JLabel("Border color:"), new GridBagConstraints(0,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,10,0,0), 0, 0)); borderColorButton = new JButton(); borderColorButton.setBackground(borderColor); borderColorButton.setPreferredSize(new Dimension(35,25)); add(borderColorButton, new GridBagConstraints(1,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2,10,2,0), 0, 0)); ++gridY; // Horizontal offset textbox add(new JLabel("Horizontal offset:"), new GridBagConstraints(0,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,10,0,0), 0, 0)); final JTextField hOffset = new JTextField("20"); hOffset.setPreferredSize(new Dimension(30,25)); add(hOffset, new GridBagConstraints(1,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2,10,2,0), 0, 0)); ++gridY; // Vertical offset textbox add(new JLabel("Vertical offset:"), new GridBagConstraints(0,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,10,0,0), 0, 0)); final JTextField vOffset = new JTextField("10"); vOffset.setPreferredSize(new Dimension(30,25)); add(vOffset, new GridBagConstraints(1,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2,10,2,0), 0, 0)); ++gridY; // Padding textbox add(new JLabel("Padding:"), new GridBagConstraints(0,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,10,0,0), 0, 0)); final JTextField padding = new JTextField("5"); padding.setPreferredSize(new Dimension(30,25)); add(padding, new GridBagConstraints(1,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2,10,2,0), 0, 0)); ++gridY; // Show icon checkbox add(new JLabel("Show an icon:"), new GridBagConstraints(0,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,10,0,0), 0, 0)); final JCheckBox showIcon = new JCheckBox(); showIcon.setSelected(false); add(showIcon, new GridBagConstraints(1,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2,10,2,0), 0, 0)); ++gridY; // Text to icon gap textbox add(new JLabel("Icon-text gap:"), new GridBagConstraints(0,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,10,0,0), 0, 0)); final JTextField iconTextGap = new JTextField("10"); iconTextGap.setPreferredSize(new Dimension(30,25)); add(iconTextGap, new GridBagConstraints(1,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2,10,2,0), 0, 0)); ++gridY; // Close button border textbox add(new JLabel("Close-button border:"), new GridBagConstraints(0,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,10,0,0), 0, 0)); final JTextField closeButtonBorder = new JTextField("5"); closeButtonBorder.setPreferredSize(new Dimension(30,25)); add(closeButtonBorder, new GridBagConstraints(1,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2,10,2,0), 0, 0)); ++gridY; // Balloon tip final JButton attachedComponent = new JButton("Show balloon tip"); add(attachedComponent, new GridBagConstraints(0,gridY,2,1,1.0,1.0, GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(50,0,25,0), 0, 0)); /* * Add the GUI's behaviour */ // Create the balloon tip balloonTip = new BalloonTip(attachedComponent, contents.getText(), new EdgedBalloonStyle(Color.WHITE, Color.BLUE), BalloonTip.Orientation.LEFT_ABOVE, BalloonTip.AttachLocation.ALIGNED, 20, 10, true); // Don't close the balloon when clicking the close-button, you just need to hide it balloonTip.setCloseButtonActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { balloonTip.setVisible(false); } }); balloonTip.setIconTextGap(Integer.parseInt(iconTextGap.getText())); int value = Integer.parseInt(closeButtonBorder.getText()); balloonTip.setCloseButtonBorder(value, value, value, value); // (Re)show the balloon tip when clicking attachedComponent attachedComponent.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { balloonTip.setVisible(true); } }); // Contents contents.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { balloonTip.setText(contents.getText()); } public void insertUpdate(DocumentEvent e) { balloonTip.setText(contents.getText()); } public void removeUpdate(DocumentEvent e) { balloonTip.setText(contents.getText()); } }); // Style stylePicker.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setBalloonTipStyle(); } }); // Fill color fillColorButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fillColor = JColorChooser.showDialog(null, "Choose a fill color", fillColor); setBalloonTipStyle(); fillColorButton.setBackground(fillColor); } }); // Border color borderColorButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { borderColor = JColorChooser.showDialog(null, "Choose a border color", borderColor); setBalloonTipStyle(); borderColorButton.setBackground(borderColor); } }); // Horizontal offset hOffset.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { setHorizontalOffset(); } public void insertUpdate(DocumentEvent e) { setHorizontalOffset(); } public void removeUpdate(DocumentEvent e) { setHorizontalOffset(); } private void setHorizontalOffset() { try { ((BasicBalloonTipPositioner)balloonTip.getPositioner()).setPreferredHorizontalOffset(Integer.parseInt(hOffset.getText())); balloonTip.revalidate(); balloonTip.refreshLocation(); } catch (Exception e) { if (!hOffset.getText().equals("")) { CompleteExample.showErrorMessage(hOffset, "Please enter a positive horizontal offset"); } } } }); // Vertical offset vOffset.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { setVerticalOffset(); } public void insertUpdate(DocumentEvent e) { setVerticalOffset(); } public void removeUpdate(DocumentEvent e) { setVerticalOffset(); } private void setVerticalOffset() { try { ((BasicBalloonTipPositioner)balloonTip.getPositioner()).setPreferredVerticalOffset(Integer.parseInt(vOffset.getText())); balloonTip.revalidate(); balloonTip.refreshLocation(); } catch (Exception e) { if (!vOffset.getText().equals("")) { CompleteExample.showErrorMessage(vOffset, "Please enter a positive vertical offset"); } } } }); // Padding padding.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { setPadding(); } public void insertUpdate(DocumentEvent e) { setPadding(); } public void removeUpdate(DocumentEvent e) { setPadding(); } private void setPadding() { try { balloonTip.setPadding(Integer.parseInt(padding.getText())); } catch (Exception e) { if (!padding.getText().equals("")) { CompleteExample.showErrorMessage(padding, "Please enter a positive padding value"); } } } }); // Show icon showIcon.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (showIcon.isSelected()) { balloonTip.setIcon(new ImageIcon(CompleteExample.class.getResource("/net/java/balloontip/images/frameicon.png"))); } else { balloonTip.setIcon(null); } } }); // Icon-text gap iconTextGap.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { setIconTextGap(); } public void insertUpdate(DocumentEvent e) { setIconTextGap(); } public void removeUpdate(DocumentEvent e) { setIconTextGap(); } private void setIconTextGap() { try { balloonTip.setIconTextGap(Integer.parseInt(iconTextGap.getText())); } catch (Exception e) { if (!iconTextGap.getText().equals("")) { CompleteExample.showErrorMessage(iconTextGap, "Please enter a positive icon-text gap value"); } } } }); // Close-button border closeButtonBorder.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { setCloseButtonBorder(); } public void insertUpdate(DocumentEvent e) { setCloseButtonBorder(); } public void removeUpdate(DocumentEvent e) { setCloseButtonBorder(); } private void setCloseButtonBorder() { try { int value = Integer.parseInt(closeButtonBorder.getText()); balloonTip.setCloseButtonBorder(value, value, value, value); } catch (Exception e) { if (!closeButtonBorder.getText().equals("")) { CompleteExample.showErrorMessage(closeButtonBorder, "Please enter a positive close-button border width"); } } } }); } private void setBalloonTipStyle() { switch (stylePicker.getSelectedIndex()) { case 0: balloonTip.setStyle(new EdgedBalloonStyle(fillColor, borderColor)); break; case 1: balloonTip.setStyle(new RoundedBalloonStyle(5, 5, fillColor, borderColor)); break; case 2: ModernBalloonStyle style = new ModernBalloonStyle(10, 10, fillColor, new Color(230,230,230), borderColor); style.setBorderThickness(3); style.enableAntiAliasing(true); balloonTip.setStyle(style); break; case 3: Color transparentFill = new Color(fillColor.getRed(), fillColor.getGreen(), fillColor.getBlue(), 180); balloonTip.setStyle(new MinimalBalloonStyle(transparentFill, 8)); break; case 4: balloonTip.setStyle(new TexturedBalloonStyle(5, 5, new ImageIcon(CompleteExample.class.getResource("/net/java/balloontip/images/bgpattern.png")).getImage(), borderColor)); break; } } } balloontip/src/net/java/balloontip/examples/complete/panels/TypesTab.java0000644000175000017500000001563211107126340027666 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.examples.complete.panels; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.Rectangle; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorListener; import javax.swing.table.TableColumn; import net.java.balloontip.BalloonTip; import net.java.balloontip.CustomBalloonTip; import net.java.balloontip.TablecellBalloonTip; import net.java.balloontip.styles.EdgedBalloonStyle; public class TypesTab extends JPanel { private TablecellBalloonTip tableBalloon; private CustomBalloonTip customBalloon; /** * Default constructor */ public TypesTab() { setLayout(new GridBagLayout()); int gridY = 0; /* * Draw the GUI */ // Regular balloon tip JPanel regularPanel = new JPanel(); regularPanel.setLayout(new GridBagLayout()); regularPanel.add(new JLabel("A BalloonTip can attach itself to JComponents (buttons, labels, text fields, ...)."), new GridBagConstraints(0,0,1,1,1.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10,10,10,0), 0, 0)); final JLabel label = new JLabel("A label"); label.setBorder(BorderFactory.createBevelBorder(1)); JPanel labelPanel = new JPanel(new GridBagLayout()); labelPanel.add(label, new GridBagConstraints(0,0,1,1,1.0,1.0, GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(10,10,10,10), 0, 0)); regularPanel.add(labelPanel, new GridBagConstraints(0,1,1,1,1.0,1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10,10,10,10), 0, 0)); regularPanel.setBorder(BorderFactory.createTitledBorder("Regular balloon tip:")); add(regularPanel, new GridBagConstraints(0,gridY,1,1,1.0,1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10,10,10,10), 0, 0)); ++gridY; // Tablecell balloon tip JPanel tableCellPanel = new JPanel(); tableCellPanel.setLayout(new GridBagLayout()); tableCellPanel.add(new JLabel("A TablecellBalloonTip can attach itself to a JTable cell."), new GridBagConstraints(0,0,1,1,1.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10,10,10,0), 0, 0)); final JTable table = new JTable(64,64); table.getModel().setValueAt("A cell", 32, 32); table.setTableHeader(null); // Remove the table header table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); TableColumn column = null; for (int i=0; i<64; ++i) { column = table.getColumnModel().getColumn(i); column.setPreferredWidth(50); } final JScrollPane tableScrollPane = new JScrollPane(table); tableCellPanel.add(tableScrollPane, new GridBagConstraints(0,1,1,1,1.0,1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10,10,10,10), 0, 0)); tableCellPanel.setBorder(BorderFactory.createTitledBorder("Table-cell balloon tip:")); add(tableCellPanel, new GridBagConstraints(0,gridY,1,1,1.0,1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10,10,10,10), 0, 0)); ++gridY; // Custom balloon tip JPanel customPanel = new JPanel(); customPanel.setLayout(new GridBagLayout()); customPanel.add(new JLabel("A CustomBalloonTip can attach itself to a rectangular shape within a JComponent."), new GridBagConstraints(0,0,1,1,1.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10,10,10,0), 0, 0)); final Rectangle customOffset = new Rectangle(640, 320, 50, 16); final JComponent customComponent = new JComponent() { protected void paintComponent(Graphics g) { Rectangle clip = g.getClipBounds(); g.setColor(Color.WHITE); g.fillRect(clip.x, clip.y, clip.width, clip.height); g.setColor(Color.BLUE); g.fillRect(customOffset.x, customOffset.y, customOffset.width, customOffset.height); } }; customComponent.setPreferredSize(new Dimension(1280, 640)); final JScrollPane customScrollPane = new JScrollPane(customComponent); customPanel.add(customScrollPane, new GridBagConstraints(0,1,1,1,1.0,1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10,10,10,10), 0, 0)); customPanel.setBorder(BorderFactory.createTitledBorder("Custom balloon tip:")); add(customPanel, new GridBagConstraints(0,gridY,1,1,1.0,1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10,10,10,10), 0, 0)); ++gridY; /* * Add the GUI's behaviour */ // Regular balloon tip new BalloonTip(label, "I'm a BalloonTip!", new EdgedBalloonStyle(Color.WHITE, Color.BLUE), BalloonTip.Orientation.LEFT_ABOVE, BalloonTip.AttachLocation.ALIGNED, 20, 20, false); // Tablecell balloon tip tableBalloon = new TablecellBalloonTip(table, "I'm a TableCellBalloonTip!", 32, 32, new EdgedBalloonStyle(Color.WHITE, Color.BLUE), BalloonTip.Orientation.LEFT_ABOVE, BalloonTip.AttachLocation.ALIGNED, 20, 20, false); tableBalloon.setViewport(tableScrollPane.getViewport()); table.addAncestorListener(new AncestorListener() { public void ancestorAdded(AncestorEvent event) { table.scrollRectToVisible(table.getCellRect(33, 38, true)); } public void ancestorMoved(AncestorEvent event) {} public void ancestorRemoved(AncestorEvent event) {} }); // Custom balloon tip customBalloon = new CustomBalloonTip(customComponent, "I'm a CustomBalloonTip!", customOffset, new EdgedBalloonStyle(Color.WHITE, Color.BLUE), BalloonTip.Orientation.LEFT_ABOVE, BalloonTip.AttachLocation.ALIGNED, 20, 20, false); customBalloon.setViewport(customScrollPane.getViewport()); customComponent.addAncestorListener(new AncestorListener() { public void ancestorAdded(AncestorEvent event) { customComponent.scrollRectToVisible(new Rectangle(876,340,10,10)); } public void ancestorMoved(AncestorEvent event) {} public void ancestorRemoved(AncestorEvent event) {} }); } } balloontip/src/net/java/balloontip/examples/complete/panels/BehaviourTab.java0000644000175000017500000002403711107126322030505 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.examples.complete.panels; import java.awt.Color; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorListener; import javax.swing.table.TableColumn; import net.java.balloontip.BalloonTip; import net.java.balloontip.TablecellBalloonTip; import net.java.balloontip.examples.complete.CompleteExample; import net.java.balloontip.positioners.BasicBalloonTipPositioner; import net.java.balloontip.positioners.Left_Above_Positioner; import net.java.balloontip.positioners.Left_Below_Positioner; import net.java.balloontip.positioners.Right_Above_Positioner; import net.java.balloontip.positioners.Right_Below_Positioner; import net.java.balloontip.styles.EdgedBalloonStyle; public class BehaviourTab extends JPanel { private JComboBox alignmentPicker; private JComboBox attachPicker; private JCheckBox offsetCorrection; private JCheckBox orientationCorrection; private TablecellBalloonTip tableBalloon; private final int HOFFSET = 40; private final int VOFFSET = 15; public BehaviourTab() { setLayout(new GridBagLayout()); int gridY = 0; /* * Draw the GUI */ // Description label add(new JLabel("Scroll around the table and notice the balloon tip's behaviour when it collides with the window's border. You can alter the balloon tip's behaviour using the settings below."), new GridBagConstraints(0,gridY,2,1,1.0,0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10,10,25,0), 0, 0)); ++gridY; // Orientation combobox add(new JLabel("Orientation:"), new GridBagConstraints(0,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,10,0,0), 0, 0)); String[] alignmentOptions = {"Left, above component", "Left, below component", "Right, above component", "Right, below component"}; alignmentPicker = new JComboBox(alignmentOptions); add(alignmentPicker, new GridBagConstraints(1,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2,10,2,0), 0, 0)); ++gridY; // Attaching location combobox add(new JLabel("Attaching location:"), new GridBagConstraints(0,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,10,0,0), 0, 0)); String[] attachOptions = {"Aligned", "Center", "North", "North east", "East", "South east", "South", "South west", "West", "North west"}; attachPicker = new JComboBox(attachOptions); add(attachPicker, new GridBagConstraints(1,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2,10,2,0), 0, 0)); ++gridY; // Offset correction checkbox add(new JLabel("Offset correction:"), new GridBagConstraints(0,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,10,0,0), 0, 0)); offsetCorrection = new JCheckBox(); offsetCorrection.setSelected(true); CompleteExample.setToolTip(offsetCorrection, "Offset correction will adjust the horizontal offset
when the balloon tip collides with the window border"); add(offsetCorrection, new GridBagConstraints(1,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2,10,2,0), 0, 0)); ++gridY; // Orientation correction checkbox add(new JLabel("Orientation correction:"), new GridBagConstraints(0,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,10,0,0), 0, 0)); orientationCorrection = new JCheckBox(); orientationCorrection.setSelected(true); CompleteExample.setToolTip(orientationCorrection, "Orientation correction will flip the balloon tip
when it collides with the window border"); add(orientationCorrection, new GridBagConstraints(1,gridY,1,1,0.0,0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2,10,2,0), 0, 0)); ++gridY; // Table final JTable table = new JTable(64,32); table.getModel().setValueAt("Cell with a balloon tip", 32, 16); table.setTableHeader(null); // Remove the table header table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); TableColumn column = null; for (int i=0; i<32; ++i) { column = table.getColumnModel().getColumn(i); column.setPreferredWidth(120); } final JScrollPane tableScrollPane = new JScrollPane(table); tableScrollPane.getHorizontalScrollBar().setUnitIncrement(3); tableScrollPane.getVerticalScrollBar().setUnitIncrement(3); add(tableScrollPane, new GridBagConstraints(0,gridY,2,1,1.0,1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10,10,10,10), 0, 0)); /* * Add the GUI's behaviour */ // Tablecell balloon tip tableBalloon = new TablecellBalloonTip(table, "Use the scrollbars to move me around!", 32, 16, new EdgedBalloonStyle(Color.WHITE, Color.BLUE), BalloonTip.Orientation.LEFT_ABOVE, BalloonTip.AttachLocation.ALIGNED, HOFFSET, VOFFSET, false); tableBalloon.setPadding(10); tableBalloon.setViewport(tableScrollPane.getViewport()); table.addAncestorListener(new AncestorListener() { public void ancestorAdded(AncestorEvent event) { table.scrollRectToVisible(table.getCellRect(38, 18, true)); } public void ancestorMoved(AncestorEvent event) {} public void ancestorRemoved(AncestorEvent event) {} }); // Alignment combo box alignmentPicker.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { BasicBalloonTipPositioner positioner = null; switch(alignmentPicker.getSelectedIndex()) { case 0: positioner = new Left_Above_Positioner(HOFFSET, VOFFSET); break; case 1: positioner = new Left_Below_Positioner(HOFFSET, VOFFSET); break; case 2: positioner = new Right_Above_Positioner(HOFFSET, VOFFSET); break; case 3: positioner = new Right_Below_Positioner(HOFFSET, VOFFSET); break; } copyPositionerSettings(((BasicBalloonTipPositioner)tableBalloon.getPositioner()), positioner); tableBalloon.setPositioner(positioner); } }); // Attach location combo box attachPicker.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ((BasicBalloonTipPositioner)tableBalloon.getPositioner()).enableFixedAttachLocation(true); switch(attachPicker.getSelectedIndex()) { case 0: ((BasicBalloonTipPositioner)tableBalloon.getPositioner()).enableFixedAttachLocation(false); break; case 1: ((BasicBalloonTipPositioner)tableBalloon.getPositioner()).setAttachLocation(0.5f, 0.5f); break; case 2: ((BasicBalloonTipPositioner)tableBalloon.getPositioner()).setAttachLocation(0.5f, 0.0f); break; case 3: ((BasicBalloonTipPositioner)tableBalloon.getPositioner()).setAttachLocation(1.0f, 0.0f); break; case 4: ((BasicBalloonTipPositioner)tableBalloon.getPositioner()).setAttachLocation(1.0f, 0.5f); break; case 5: ((BasicBalloonTipPositioner)tableBalloon.getPositioner()).setAttachLocation(1.0f, 1.0f); break; case 6: ((BasicBalloonTipPositioner)tableBalloon.getPositioner()).setAttachLocation(0.5f, 1.0f); break; case 7: ((BasicBalloonTipPositioner)tableBalloon.getPositioner()).setAttachLocation(0.0f, 1.0f); break; case 8: ((BasicBalloonTipPositioner)tableBalloon.getPositioner()).setAttachLocation(0.0f, 0.5f); break; case 9: ((BasicBalloonTipPositioner)tableBalloon.getPositioner()).setAttachLocation(0.0f, 0.0f); break; } tableBalloon.refreshLocation(); } }); // Offset correction offsetCorrection.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (offsetCorrection.isSelected()) { ((BasicBalloonTipPositioner)tableBalloon.getPositioner()).enableOffsetCorrection(true); } else { ((BasicBalloonTipPositioner)tableBalloon.getPositioner()).enableOffsetCorrection(false); } tableBalloon.refreshLocation(); } }); // Orientation correction orientationCorrection.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (orientationCorrection.isSelected()) { ((BasicBalloonTipPositioner)tableBalloon.getPositioner()).enableOrientationCorrection(true); } else { ((BasicBalloonTipPositioner)tableBalloon.getPositioner()).enableOrientationCorrection(false); } tableBalloon.refreshLocation(); } }); } private void copyPositionerSettings(final BasicBalloonTipPositioner oldPositioner, BasicBalloonTipPositioner newPositioner) { newPositioner.enableOffsetCorrection(oldPositioner.isOffsetCorrected()); newPositioner.enableOrientationCorrection(oldPositioner.isOrientationCorrected()); newPositioner.enableFixedAttachLocation(oldPositioner.isFixedAttachLocation()); newPositioner.setAttachLocation(oldPositioner.getAttachLocationX(), oldPositioner.getAttachLocationY()); } }balloontip/src/net/java/balloontip/examples/complete/panels/MainPanel.java0000644000175000017500000000331011107126332027766 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.examples.complete.panels; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import javax.swing.JPanel; import javax.swing.JTabbedPane; /** * Panel that contains all tabs of the Balloontip example application * @author Tim Molderez */ public class MainPanel extends JPanel { /** * Default constructor */ public MainPanel() { setLayout(new GridBagLayout()); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.setTabPlacement(JTabbedPane.TOP); tabbedPane.addTab("Looks", new LooksTab()); tabbedPane.addTab("Behaviour", new BehaviourTab()); tabbedPane.addTab("Types", new TypesTab()); tabbedPane.addTab("Utilities", new UtilitiesTab()); add(tabbedPane, new GridBagConstraints(0,0,1,1,1,1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10,10,10,10), 0, 0)); } } balloontip/src/net/java/balloontip/examples/complete/CompleteExample.java0000644000175000017500000000642111107126312027730 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.examples.complete; import java.awt.Color; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JFrame; import net.java.balloontip.BalloonTip; import net.java.balloontip.examples.complete.panels.MainPanel; import net.java.balloontip.styles.BalloonTipStyle; import net.java.balloontip.styles.MinimalBalloonStyle; import net.java.balloontip.utils.TimingUtils; import net.java.balloontip.utils.ToolTipUtils; /** * Main class for the Balloontip example application * @author Tim Molderez */ public class CompleteExample { private static BalloonTip errBalloon = null; /** * Main method * @param args command-line arguments (unused) */ public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame("BalloonTip example"); frame.setIconImage(new ImageIcon(CompleteExample.class.getResource("/net/java/balloontip/images/frameicon.png")).getImage()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(new MainPanel()); frame.pack(); frame.setSize(540, 640); frame.setLocationRelativeTo(null); // Centers the frame on the screen frame.setVisible(true); } }); } /** * Set a tooltip * @param comp sets a tooltip for this component * @param text the contents of the tooltip (you may use html) */ public static void setToolTip(final JComponent comp, final String text) { BalloonTipStyle style = new MinimalBalloonStyle(new Color(169, 205, 221, 220), 5); final BalloonTip balloon = new BalloonTip(comp, text, style, BalloonTip.Orientation.LEFT_ABOVE, BalloonTip.AttachLocation.ALIGNED, 15, 10, false); balloon.enableClickToHide(true); ToolTipUtils.balloonToToolTip(balloon, 500, 3000); } /** * Display an error balloon tip * @param comp attach the balloon tip to this component * @param text error message */ public static void showErrorMessage(JComponent comp, String text) { if (errBalloon!=null) { errBalloon.closeBalloon(); } BalloonTipStyle style = new MinimalBalloonStyle(new Color(246, 197, 192, 220), 5); errBalloon = new BalloonTip(comp, "" + text + "", style, BalloonTip.Orientation.LEFT_ABOVE, BalloonTip.AttachLocation.ALIGNED, 15, 10, false); errBalloon.enableClickToHide(true); TimingUtils.showTimedBalloon(errBalloon, 3000); } } balloontip/src/net/java/balloontip/positioners/0000755000175000017500000000000011063222124022725 5ustar handschuhhandschuhballoontip/src/net/java/balloontip/positioners/Right_Below_Positioner.java0000644000175000017500000000630211107126540030215 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.positioners; import java.awt.Rectangle; /** * This class positions a balloon tip below the component it's attached to, with the tip on the right * @author Tim Molderez */ public class Right_Below_Positioner extends BasicBalloonTipPositioner { public Right_Below_Positioner(int hO, int vO) { super(hO, vO); } public void determineAndSetLocation(Rectangle attached) { // First calculate the location, without applying any correction tricks int balloonWidth = balloonTip.getPreferredSize().width; int balloonHeight = balloonTip.getPreferredSize().height; flipX = true; flipY = true; hOffset = balloonWidth - preferredHorizontalOffset; if (fixedAttachLocation) { x = new Float(attached.x + attached.width * attachLocationX).intValue() - hOffset; y = new Float(attached.y + attached.height * attachLocationY).intValue(); } else { x = attached.x + attached.width - balloonWidth; y = attached.y + attached.height; } // Apply orientation correction if (orientationCorrection) { // Check collision with the bottom of the window if (y + balloonHeight > balloonTip.getTopLevelContainer().getHeight()) { flipY = false; if (fixedAttachLocation) { y -= balloonHeight; } else { y = attached.y - balloonHeight; } } // Check collision with the right side of the window if (x + balloonWidth > balloonTip.getTopLevelContainer().getWidth()) { flipX = false; hOffset = balloonWidth - hOffset; if (fixedAttachLocation) { x += (balloonWidth - 2*hOffset); } else { x = attached.x; } } } // Apply offset correction if (offsetCorrection) { applyOffsetCorrection(); } // Finally set the balloon tip's location if (flipX) { balloonTip.getStyle().setHorizontalOffset(balloonWidth - hOffset); } else { balloonTip.getStyle().setHorizontalOffset(hOffset); } balloonTip.getStyle().flip(flipX, flipY); balloonTip.setBounds(x, y, balloonTip.getPreferredSize().width, balloonTip.getPreferredSize().height); balloonTip.revalidate(); // Revalidate is needed in case the balloon gets flipped; validate wouldn't do in that case. if (hOffset != preferredHorizontalOffset) { balloonTip.repaint(); // In certain cases, when the horizontal offset changes, it doesn't get redrawn properly without a repaint... } } } balloontip/src/net/java/balloontip/positioners/BasicBalloonTipPositioner.java0000644000175000017500000002065311107126514030664 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.positioners; import java.awt.Point; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import net.java.balloontip.BalloonTip; import net.java.balloontip.styles.BalloonTipStyle; /** * Provides the interface for a basic positioner */ public abstract class BasicBalloonTipPositioner extends BalloonTipPositioner { protected int x = 0; // Current position protected int y = 0; protected int hOffset = 0; // Current horizontal offset protected boolean flipX = false; // Current orientation protected boolean flipY = false; protected int preferredHorizontalOffset; // The preferred value of the horizontal offset protected int preferredVerticalOffset; // The preferred value of the vertical offset protected int minimumHorizontalOffset; // The horizontal offset may not become smaller than this value protected boolean offsetCorrection = true; // If true, a balloon tip should adjust its horizontal offset when the left/right side collides with the window's border protected boolean orientationCorrection = true; // If true, a balloon tip should flip/mirror itself if otherwise it would become invisible protected boolean fixedAttachLocation = false; // If true, attachLocationX and attachLocationY should be used to determine the position of the tip protected float attachLocationX = 0.0f; // A percentage that determines the X-location of the tip on the attached object protected float attachLocationY = 0.0f; // A percentage that determines the Y-location of the tip on the attached object // For example, if attachLocationX and Y are both 0.5, then the tip is centered on the attached object /** * Constructor * @param hO Preferred horizontal offset * @param vO Preferred vertical offset */ public BasicBalloonTipPositioner(int hO, int vO) { preferredHorizontalOffset = hO; preferredVerticalOffset = vO; } public void setBalloonTip(final BalloonTip balloonTip) { // Set up the new balloon tip this.balloonTip = balloonTip; balloonTip.getStyle().setHorizontalOffset(preferredHorizontalOffset); balloonTip.getStyle().setVerticalOffset(preferredVerticalOffset); minimumHorizontalOffset = balloonTip.getStyle().getMinimalHorizontalOffset(); // Whenever the style changes, make sure to set up the new style properly balloonTip.addPropertyChangeListener("style", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { BalloonTipStyle style = ((BalloonTipStyle)evt.getNewValue()); style.setHorizontalOffset(preferredHorizontalOffset); style.setVerticalOffset(preferredVerticalOffset); minimumHorizontalOffset = style.getMinimalHorizontalOffset(); } }); } /** * Retrieve the preferred horizontal offset * @return Preferred horizontal offset */ public int getPreferredHorizontalOffset() { return preferredHorizontalOffset; } /** * Set the preferred horizontal offset * @param preferredHorizontalOffset */ public void setPreferredHorizontalOffset(int preferredHorizontalOffset) { this.preferredHorizontalOffset = preferredHorizontalOffset; balloonTip.getStyle().setHorizontalOffset(preferredHorizontalOffset); balloonTip.repaint(); } /** * Retrieve the preferred vertical offset * @return Preferred vertical offset */ public int getPreferredVerticalOffset() { return preferredVerticalOffset; } /** * Set the preferred horizontal offset * @param preferredVerticalOffset */ public void setPreferredVerticalOffset(int preferredVerticalOffset) { this.preferredVerticalOffset = preferredVerticalOffset; this.minimumHorizontalOffset = 2 * preferredVerticalOffset; balloonTip.getStyle().setVerticalOffset(preferredVerticalOffset); } /** * Is offset correction enabled? * @return True if offset correction is enabled */ public boolean isOffsetCorrected() { return offsetCorrection; } /** * Set offset correction * @param offsetCorrection enabled if true */ public void enableOffsetCorrection(boolean offsetCorrection) { this.offsetCorrection = offsetCorrection; } /** * Is orientation correction enabled? * @return True if orientation correction is enabled */ public boolean isOrientationCorrected() { return orientationCorrection; } /** * Set orientation correction * @param orientationCorrection enabled if true */ public void enableOrientationCorrection(boolean orientationCorrection) { this.orientationCorrection = orientationCorrection; } /** * Does the tip have a fixed location? * @return True if the balloon has a fixed attaching location */ public boolean isFixedAttachLocation() { return fixedAttachLocation; } /** * Set whether the tip should have a fixed location * @param fixedAttachLocation the tip has a fixed location if true */ public void enableFixedAttachLocation(boolean fixedAttachLocation) { this.fixedAttachLocation = fixedAttachLocation; } /** * Returns the percentage that determines the X-coordinate of the tip within the attached component * (whereas 0.0 is the left side and 1.0 is the right side) * @return The percentage that determines the X-coordinate of the attaching location */ public float getAttachLocationX() { return attachLocationX; } /** * Returns the percentage that determines the Y-coordinate of the tip within the attached component * (whereas 0.0 is the top and 1.0 is the bottom) * @return The percentage that determines the Y-coordinate of the attaching location */ public float getAttachLocationY() { return attachLocationY; } /** * Set where the tip should be located, relative to the component the balloon is attached to. * @param attachLocationX a number from 0.0 to 1.0 (whereas 0 is the left side; 1 is the right side) * @param attachLocationY a number from 0.0 to 1.0 (whereas 0 is the top; 1 is the bottom) */ public void setAttachLocation(float attachLocationX, float attachLocationY) { this.attachLocationX = attachLocationX; this.attachLocationY = attachLocationY; } public Point getTipLocation() { int tipX = x + hOffset; int tipY = y + balloonTip.getHeight(); if (flipX) { tipX = x + hOffset; } if (flipY) { tipY = y; } return new Point(tipX, tipY); } /* * Applies offset correction to the current position of the balloon tip */ protected void applyOffsetCorrection() { // Check collision with the left side of the window int overflow = -x; int balloonWidth = balloonTip.getWidth(); if (overflow > 0) { x += overflow; hOffset -= overflow; // Take into account the minimum horizontal offset if (hOffset < minimumHorizontalOffset) { hOffset = minimumHorizontalOffset; if (flipX) { x += -overflow + (balloonWidth - preferredHorizontalOffset) - minimumHorizontalOffset; }else { x += -overflow + preferredHorizontalOffset - minimumHorizontalOffset; } } } // Check collision with the right side of the window overflow = (x+balloonWidth) - balloonTip.getTopLevelContainer().getWidth(); if (overflow > 0) { x -= overflow; hOffset += overflow; // Take into account the minimum horizontal offset if (hOffset > balloonWidth - minimumHorizontalOffset) { hOffset = balloonWidth - minimumHorizontalOffset; if (flipX) { x += overflow + preferredHorizontalOffset + minimumHorizontalOffset; }else { x += overflow - (balloonWidth - preferredHorizontalOffset) + minimumHorizontalOffset; } } } } }balloontip/src/net/java/balloontip/positioners/BalloonTipPositioner.java0000644000175000017500000000432211107126510027711 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.positioners; import java.awt.Point; import java.awt.Rectangle; import net.java.balloontip.BalloonTip; /** * A BalloonTipPositioner is used to determine the position of a BalloonTip * Note: If you change a positioner's settings, the changes may not be visible until the balloon tip is redrawn. * @author Tim Molderez */ public abstract class BalloonTipPositioner { protected BalloonTip balloonTip = null; /** * Default constructor */ public BalloonTipPositioner() {} /** * Retrieve the balloon tip that uses this positioner * @return The balloon tip that uses this positioner */ public BalloonTip getBalloonTip() { return balloonTip; } /** * This method is meant only to be used by BalloonTip! * A BalloonTip must call this method at the end of its construction (or when it's swapping for a new BalloonTipPositioner) * @param balloonTip */ public void setBalloonTip(final BalloonTip balloonTip) { this.balloonTip = balloonTip; } /** * Find the current location of the balloon's tip, relative to the top level container * @return The location of the tip */ public abstract Point getTipLocation(); /** * Determine and set the current location of the balloon tip * @param attached the balloon tip is attached to this rectangle */ public abstract void determineAndSetLocation(Rectangle attached); }balloontip/src/net/java/balloontip/positioners/Right_Above_Positioner.java0000644000175000017500000000622311107126534030206 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.positioners; import java.awt.Rectangle; /** * This class positions a balloon tip above the component it's attached to, with the tip on the right * @author Tim Molderez */ public class Right_Above_Positioner extends BasicBalloonTipPositioner { public Right_Above_Positioner(int hO, int vO) { super(hO, vO); } public void determineAndSetLocation(Rectangle attached) { // First calculate the location, without applying any correction tricks int balloonWidth = balloonTip.getPreferredSize().width; int balloonHeight = balloonTip.getPreferredSize().height; flipX = true; flipY = false; hOffset = balloonWidth - preferredHorizontalOffset; if (fixedAttachLocation) { x = new Float(attached.x + attached.width * attachLocationX).intValue() - hOffset; y = new Float(attached.y + attached.height * attachLocationY).intValue() - balloonHeight; } else { x = attached.x + attached.width - balloonWidth; y = attached.y - balloonHeight; } // Apply orientation correction if (orientationCorrection) { // Check collision with the top of the window if (y < 0) { flipY = true; if (fixedAttachLocation) { y += balloonHeight; } else { y = attached.y + attached.height; } } // Check collision with the right side of the window if (x + balloonWidth > balloonTip.getTopLevelContainer().getWidth()) { flipX = false; hOffset = balloonWidth - hOffset; if (fixedAttachLocation) { x += (balloonWidth - 2*hOffset); } else { x = attached.x; } } } // Apply offset correction if (offsetCorrection) { applyOffsetCorrection(); } // Finally set the balloon tip's location if (flipX) { balloonTip.getStyle().setHorizontalOffset(balloonWidth - hOffset); } else { balloonTip.getStyle().setHorizontalOffset(hOffset); } balloonTip.getStyle().flip(flipX, flipY); balloonTip.setBounds(x, y, balloonTip.getPreferredSize().width, balloonTip.getPreferredSize().height); balloonTip.revalidate(); // Revalidate is needed in case the balloon gets flipped; validate wouldn't do in that case. if (hOffset != preferredHorizontalOffset) { balloonTip.repaint(); // In certain cases, when the horizontal offset changes, it doesn't get redrawn properly without a repaint... } } } balloontip/src/net/java/balloontip/positioners/Left_Below_Positioner.java0000644000175000017500000000616711107126526030047 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.positioners; import java.awt.Rectangle; /** * This class positions a balloon tip below the component it's attached to, with the tip on the left * @author Tim Molderez */ public class Left_Below_Positioner extends BasicBalloonTipPositioner { public Left_Below_Positioner(int hO, int vO) { super(hO, vO); } public void determineAndSetLocation(Rectangle attached) { // First calculate the location, without applying any correction tricks int balloonWidth = balloonTip.getPreferredSize().width; int balloonHeight = balloonTip.getPreferredSize().height; flipX = false; flipY = true; hOffset = preferredHorizontalOffset; if (fixedAttachLocation) { x = new Float(attached.x + attached.width * attachLocationX).intValue() - hOffset; y = new Float(attached.y + attached.height * attachLocationY).intValue(); } else { x = attached.x; y = attached.y + attached.height; } // Apply orientation correction if (orientationCorrection) { // Check collision with the bottom of the window if (y + balloonHeight > balloonTip.getTopLevelContainer().getHeight()) { flipY = false; if (fixedAttachLocation) { y -= balloonHeight; } else { y = attached.y - balloonHeight; } } // Check collision with the left side of the window if (x < 0) { flipX = true; if (fixedAttachLocation) { x -= balloonWidth - 2*hOffset; } else { x = attached.x + attached.width - balloonWidth; } hOffset = balloonWidth - hOffset; } } // Apply offset correction if (offsetCorrection) { applyOffsetCorrection(); } // Finally set the balloon tip's location if (flipX) { balloonTip.getStyle().setHorizontalOffset(balloonWidth - hOffset); } else { balloonTip.getStyle().setHorizontalOffset(hOffset); } balloonTip.getStyle().flip(flipX, flipY); balloonTip.setBounds(x, y, balloonTip.getPreferredSize().width, balloonTip.getPreferredSize().height); balloonTip.revalidate(); // Revalidate is needed in case the balloon gets flipped; validate wouldn't do in that case. if (hOffset != preferredHorizontalOffset) { balloonTip.repaint(); // In certain cases, when the horizontal offset changes, it doesn't get redrawn properly without a repaint... } } } balloontip/src/net/java/balloontip/positioners/Left_Above_Positioner.java0000644000175000017500000000611611107126522030021 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.positioners; import java.awt.Rectangle; /** * This class positions a balloon tip above the component it's attached to, with the tip on the left * @author Tim Molderez */ public class Left_Above_Positioner extends BasicBalloonTipPositioner { public Left_Above_Positioner(int hO, int vO) { super(hO, vO); } public void determineAndSetLocation(Rectangle attached) { // First calculate the location, without applying any correction tricks int balloonWidth = balloonTip.getPreferredSize().width; int balloonHeight = balloonTip.getPreferredSize().height; flipX = false; flipY = false; hOffset = preferredHorizontalOffset; if (fixedAttachLocation) { x = new Float(attached.x + attached.width * attachLocationX).intValue() - hOffset; y = new Float(attached.y + attached.height * attachLocationY).intValue() - balloonHeight; } else { x = attached.x; y = attached.y - balloonHeight; } // Apply orientation correction if (orientationCorrection) { // Check collision with the top of the window if (y < 0) { flipY = true; if (fixedAttachLocation) { y += balloonHeight; } else { y = attached.y + attached.height; } } // Check collision with the left side of the window if (x < 0) { flipX = true; if (fixedAttachLocation) { x -= balloonWidth - 2*hOffset; } else { x = attached.x + attached.width - balloonWidth; } hOffset = balloonWidth - hOffset; } } // Apply offset correction if (offsetCorrection) { applyOffsetCorrection(); } // Finally set the balloon tip's location if (flipX) { balloonTip.getStyle().setHorizontalOffset(balloonWidth - hOffset); } else { balloonTip.getStyle().setHorizontalOffset(hOffset); } balloonTip.getStyle().flip(flipX, flipY); balloonTip.setBounds(x, y, balloonTip.getPreferredSize().width, balloonTip.getPreferredSize().height); balloonTip.revalidate(); // Revalidate is needed in case the balloon gets flipped; validate wouldn't do in that case. if (hOffset != preferredHorizontalOffset) { balloonTip.repaint(); // In certain cases, when the horizontal offset changes, it doesn't get redrawn properly without a repaint... } } }balloontip/src/net/java/balloontip/utils/0000755000175000017500000000000011065466344021527 5ustar handschuhhandschuhballoontip/src/net/java/balloontip/utils/ImageUtils.java0000644000175000017500000001100511107126762024424 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.utils; import java.awt.Graphics; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.HeadlessException; import java.awt.Image; import java.awt.Transparency; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.PixelGrabber; import javax.swing.ImageIcon; /** * Some methods for use with an Image * @author Tim Molderez */ public class ImageUtils { /* * Disallow instantiating this class */ private ImageUtils() {}; /** * This method returns true if the specified image has transparent pixels * This snippet was taken from: http://www.exampledepot.com/egs/java.awt.image/HasAlpha.html * @param image * @return True if the image has any transparency */ public static boolean hasAlpha(Image image) { // If buffered image, the color model is readily available if (image instanceof BufferedImage) { BufferedImage bimage = (BufferedImage)image; return bimage.getColorModel().hasAlpha(); } // Use a pixel grabber to retrieve the image's color model; // grabbing a single pixel is usually sufficient PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false); try { pg.grabPixels(); } catch (InterruptedException e) { } // Get the image's color model ColorModel cm = pg.getColorModel(); return cm.hasAlpha(); } /** * This method returns a buffered image with the contents of an image * This snippet was taken from: http://www.exampledepot.com/egs/java.awt.image/Image2Buf.html * @param image * @return The buffered image */ public static BufferedImage toBufferedImage(Image image) { if (image instanceof BufferedImage) { return (BufferedImage)image; } // This code ensures that all the pixels in the image are loaded image = new ImageIcon(image).getImage(); // Determine if the image has transparent pixels; for this method's // implementation, see e661 Determining If an Image Has Transparent Pixels boolean hasAlpha = hasAlpha(image); // Create a buffered image with a format that's compatible with the screen BufferedImage bimage = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { // Determine the type of transparency of the new buffered image int transparency = Transparency.OPAQUE; if (hasAlpha) { transparency = Transparency.BITMASK; } // Create the buffered image GraphicsDevice gs = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gs.getDefaultConfiguration(); bimage = gc.createCompatibleImage( image.getWidth(null), image.getHeight(null), transparency); } catch (HeadlessException e) { // The system does not have a screen } if (bimage == null) { // Create a buffered image using the default color model int type = BufferedImage.TYPE_INT_RGB; if (hasAlpha) { type = BufferedImage.TYPE_INT_ARGB; } bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); } // Copy image to buffered image Graphics g = bimage.createGraphics(); // Paint the image onto the buffered image g.drawImage(image, 0, 0, null); g.dispose(); return bimage; } } balloontip/src/net/java/balloontip/utils/FlipUtils.java0000644000175000017500000000352311107126754024303 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.utils; import java.awt.Point; /** * A helper class for flipping/mirroring points * @author Bernhard Pauler */ public class FlipUtils { /* * Disallow instantiating this class */ private FlipUtils() {}; /** * Flip a point around a horizontal axis * @param x X-coordinate of the point * @param y Y-coordinate of the point * @param flipAxis Y-coordinate that defines the horizontal axis * @return the flipped point */ public static Point flipHorizontally(int x, int y, int flipAxis) { Point p = new Point(x, y); p.move(p.x, flipAxis-p.y); return p; } /** * Flip a point around a vertical axis * @param x X-coordinate of the point * @param y Y-coordinate of the point * @param flipAxis X-coordinate that defines the vertical axis * @return the flipped point */ public static Point flipVertically(int x, int y, int flipAxis) { Point p = new Point(x, y); p.move(flipAxis-p.x, p.y); return p; } } balloontip/src/net/java/balloontip/utils/ToolTipUtils.java0000644000175000017500000000603411107127004024770 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.utils; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.Timer; import net.java.balloontip.BalloonTip; /** * This class allows you to use a balloon tip as a tooltip * @author Tim Molderez */ public class ToolTipUtils { /* * Disallow instantiating this class */ private ToolTipUtils() {}; /* * This class monitors when the balloon tooltip should be shown */ private static class ToolTipController extends MouseAdapter { private BalloonTip balloonTip; private Timer initialTimer; private Timer showTimer; /** * Constructor * @param balloonTip * @param initialDelay in milliseconds, how long should you hover over the attached component before showing the tooltip * @param showDelay in milliseconds, how long should the tooltip stay visible */ public ToolTipController(final BalloonTip balloonTip, int initialDelay, int showDelay) { super(); this.balloonTip = balloonTip; initialTimer = new Timer(initialDelay, new ActionListener() { public void actionPerformed(ActionEvent e) { balloonTip.setVisible(true); showTimer.start(); } }); initialTimer.setRepeats(false); showTimer = new Timer(showDelay, new ActionListener() { public void actionPerformed(ActionEvent e) { balloonTip.setVisible(false); } }); showTimer.setRepeats(false); } public void mouseEntered(MouseEvent e) { if (!balloonTip.isVisible()) { initialTimer.start(); } } public void mouseExited(MouseEvent e) { initialTimer.stop(); } }; /** * Turns a balloon tip into a tooltip * @param bT the balloon tip * @param initialDelay in milliseconds, how long should you hover over the attached component before showing the tooltip * @param showDelay in milliseconds, how long should the tooltip stay visible */ public static void balloonToToolTip(final BalloonTip bT, int initialDelay, int showDelay) { bT.setVisible(false); // Add tooltip behaviour bT.getAttachedComponent().addMouseListener(new ToolTipController(bT, initialDelay, showDelay)); } } balloontip/src/net/java/balloontip/utils/TimingUtils.java0000644000175000017500000000323711107126776024646 0ustar handschuhhandschuh/** * Balloontip - Balloon tips for Java Swing applications * Copyright 2007, 2008 Bernhard Pauler, Tim Molderez * * This file is part of Balloontip. * * Balloontip is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Balloontip is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Balloontip. If not, see . */ package net.java.balloontip.utils; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.Timer; import net.java.balloontip.BalloonTip; /** * This class provides timed balloon tips * @author Tim */ public class TimingUtils { /* * Disallow instantiating this class */ private TimingUtils() {}; /** * Displays a balloon tip for a certain time. * @param balloon the BalloonTip * @param time show the balloon for this amount of milliseconds */ public static void showTimedBalloon(final BalloonTip balloon, Integer time) { balloon.setVisible(true); Timer timer = new Timer(0, new ActionListener() { public void actionPerformed(ActionEvent e) { balloon.closeBalloon(); } }); timer.setRepeats(false); timer.setInitialDelay(time); timer.start(); } } balloontip/build.xml0000644000175000017500000000516111107131050015526 0ustar handschuhhandschuh Balloontip]]> https://balloontip.dev.java.net/]]> balloontip/gpl.txt0000644000175000017500000010451311107121204015231 0ustar handschuhhandschuh GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . balloontip/MANIFEST.MF0000644000175000017500000000013010752170776015355 0ustar handschuhhandschuhManifest-Version: 1.0 Main-Class: net.java.balloontip.examples.complete.CompleteExampleballoontip/README.txt0000644000175000017500000000034411066442672015424 0ustar handschuhhandschuhBalloontip --- Quick readme To start the demo application: Double-click balloontip_with_examples_ ... .jar To use balloon tips in your project: Use balloontip_ ... .jar For more information: Check doc/manual/index.htmballoontip/lgpl.txt0000644000175000017500000001672711107121210015413 0ustar handschuhhandschuh GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.