Added code folding and formatted all files

This commit is contained in:
SuspiciousActivity committed 2018-07-08 14:39:06 +02:00
1 parent 11570d6b95
commit 66cd1dbd3e
233 files changed
+82245 -118134

No files matched your search

+62 -82
View File
@@ -1,10 +1,8 @@
/*
* 12/23/2008
*
* SizeGrip.java - A size grip component that sits at the bottom of the window,
* allowing the user to easily resize that window.
*
* This library is distributed under a modified BSD license. See the included
* This library is distributed under a modified BSD license. See the included
* AutoComplete.License.txt file for details.
*/
package org.fife.ui.autocomplete;
@@ -22,16 +20,16 @@ import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.event.MouseInputAdapter;
/**
* A component that allows its parent window to be resizable, similar to the
* size grip seen on status bars. This is essentially a copy of the class with
* size grip seen on status bars. This is essentially a copy of the class with
* the same name in RSyntaxTextArea, but is duplicated to prevent a dependency
* on that library.
*
@@ -39,34 +37,32 @@ import javax.swing.event.MouseInputAdapter;
* @version 1.0
*/
class SizeGrip extends JPanel {
/**
* The size grip to use if we're on OS X.
*/
private Image osxSizeGrip;
public SizeGrip() {
MouseHandler adapter = new MouseHandler();
addMouseListener(adapter);
addMouseMotionListener(adapter);
setPreferredSize(new Dimension(16, 16));
}
/**
* Overridden to ensure that the cursor for this component is appropriate
* for the orientation.
*
* @param o The new orientation.
* @param o
* The new orientation.
*/
@Override
public void applyComponentOrientation(ComponentOrientation o) {
possiblyFixCursor(o.isLeftToRight());
super.applyComponentOrientation(o);
}
/**
* Creates and returns the OS X size grip image.
*
@@ -75,7 +71,7 @@ class SizeGrip extends JPanel {
private Image createOSXSizeGrip() {
ClassLoader cl = getClass().getClassLoader();
URL url = cl.getResource("org/fife/ui/autocomplete/osx_sizegrip.png");
if (url==null) {
if (url == null) {
// We're not running in a jar - we may be debugging in Eclipse,
// for example
File f = new File("../AutoComplete/src/org/fife/ui/autocomplete/osx_sizegrip.png");
@@ -86,8 +82,7 @@ class SizeGrip extends JPanel {
mue.printStackTrace();
return null;
}
}
else {
} else {
return null; // Can't find resource or image file
}
}
@@ -99,102 +94,91 @@ class SizeGrip extends JPanel {
}
return image;
}
/**
* Paints this panel.
*
* @param g The graphics context.
* @param g
* The graphics context.
*/
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Dimension dim = getSize();
if (osxSizeGrip!=null) {
g.drawImage(osxSizeGrip, dim.width-16, dim.height-16, null);
if (osxSizeGrip != null) {
g.drawImage(osxSizeGrip, dim.width - 16, dim.height - 16, null);
return;
}
Color c1 = UIManager.getColor("Label.disabledShadow");
Color c2 = UIManager.getColor("Label.disabledForeground");
ComponentOrientation orientation = getComponentOrientation();
if (orientation.isLeftToRight()) {
int width = dim.width -= 3;
int width = dim.width -= 3;
int height = dim.height -= 3;
g.setColor(c1);
g.fillRect(width-9,height-1, 3,3);
g.fillRect(width-5,height-1, 3,3);
g.fillRect(width-1,height-1, 3,3);
g.fillRect(width-5,height-5, 3,3);
g.fillRect(width-1,height-5, 3,3);
g.fillRect(width-1,height-9, 3,3);
g.fillRect(width - 9, height - 1, 3, 3);
g.fillRect(width - 5, height - 1, 3, 3);
g.fillRect(width - 1, height - 1, 3, 3);
g.fillRect(width - 5, height - 5, 3, 3);
g.fillRect(width - 1, height - 5, 3, 3);
g.fillRect(width - 1, height - 9, 3, 3);
g.setColor(c2);
g.fillRect(width-9,height-1, 2,2);
g.fillRect(width-5,height-1, 2,2);
g.fillRect(width-1,height-1, 2,2);
g.fillRect(width-5,height-5, 2,2);
g.fillRect(width-1,height-5, 2,2);
g.fillRect(width-1,height-9, 2,2);
}
else {
g.fillRect(width - 9, height - 1, 2, 2);
g.fillRect(width - 5, height - 1, 2, 2);
g.fillRect(width - 1, height - 1, 2, 2);
g.fillRect(width - 5, height - 5, 2, 2);
g.fillRect(width - 1, height - 5, 2, 2);
g.fillRect(width - 1, height - 9, 2, 2);
} else {
int height = dim.height -= 3;
g.setColor(c1);
g.fillRect(10,height-1, 3,3);
g.fillRect(6,height-1, 3,3);
g.fillRect(2,height-1, 3,3);
g.fillRect(6,height-5, 3,3);
g.fillRect(2,height-5, 3,3);
g.fillRect(2,height-9, 3,3);
g.fillRect(10, height - 1, 3, 3);
g.fillRect(6, height - 1, 3, 3);
g.fillRect(2, height - 1, 3, 3);
g.fillRect(6, height - 5, 3, 3);
g.fillRect(2, height - 5, 3, 3);
g.fillRect(2, height - 9, 3, 3);
g.setColor(c2);
g.fillRect(10,height-1, 2,2);
g.fillRect(6,height-1, 2,2);
g.fillRect(2,height-1, 2,2);
g.fillRect(6,height-5, 2,2);
g.fillRect(2,height-5, 2,2);
g.fillRect(2,height-9, 2,2);
g.fillRect(10, height - 1, 2, 2);
g.fillRect(6, height - 1, 2, 2);
g.fillRect(2, height - 1, 2, 2);
g.fillRect(6, height - 5, 2, 2);
g.fillRect(2, height - 5, 2, 2);
g.fillRect(2, height - 9, 2, 2);
}
}
/**
* Ensures that the cursor for this component is appropriate for the
* orientation.
*
* @param ltr Whether the current component orientation is LTR.
* @param ltr
* Whether the current component orientation is LTR.
*/
protected void possiblyFixCursor(boolean ltr) {
int cursor = Cursor.NE_RESIZE_CURSOR;
if (ltr) {
cursor = Cursor.NW_RESIZE_CURSOR;
}
if (cursor!=getCursor().getType()) {
if (cursor != getCursor().getType()) {
setCursor(Cursor.getPredefinedCursor(cursor));
}
}
@Override
public void updateUI() {
super.updateUI();
// TODO: Key off of Aqua LaF, not just OS X, as this size grip looks
// bad on other LaFs on Mac such as Nimbus.
if (System.getProperty("os.name").contains("OS X")) {
if (osxSizeGrip==null) {
if (osxSizeGrip == null) {
osxSizeGrip = createOSXSizeGrip();
}
}
else { // Clear memory in case of runtime LaF change.
} else { // Clear memory in case of runtime LaF change.
osxSizeGrip = null;
}
}
/**
* Listens for mouse events on this panel and resizes the parent window
* appropriately.
@@ -206,9 +190,9 @@ class SizeGrip extends JPanel {
* started happening somewhere - our window would grow way too large.
*/
private class MouseHandler extends MouseInputAdapter {
private Point origPos;
@Override
public void mouseDragged(MouseEvent e) {
Point newPos = e.getPoint();
@@ -216,21 +200,20 @@ class SizeGrip extends JPanel {
int xDelta = newPos.x - origPos.x;
int yDelta = newPos.y - origPos.y;
Window wind = SwingUtilities.getWindowAncestor(SizeGrip.this);
if (wind!=null) { // Should always be true
if (wind != null) { // Should always be true
if (getComponentOrientation().isLeftToRight()) {
int w = wind.getWidth();
if (newPos.x>=wind.getX()) {
if (newPos.x >= wind.getX()) {
w += xDelta;
}
int h = wind.getHeight();
if (newPos.y>=wind.getY()) {
if (newPos.y >= wind.getY()) {
h += yDelta;
}
wind.setSize(w,h);
}
else { // RTL
int newW = Math.max(1, wind.getWidth()-xDelta);
int newH = Math.max(1, wind.getHeight()+yDelta);
wind.setSize(w, h);
} else { // RTL
int newW = Math.max(1, wind.getWidth() - xDelta);
int newH = Math.max(1, wind.getHeight() + yDelta);
wind.setBounds(newPos.x, wind.getY(), newW, newH);
}
// invalidate()/validate() needed pre-1.6.
@@ -239,19 +222,16 @@ class SizeGrip extends JPanel {
}
origPos.setLocation(newPos);
}
@Override
public void mousePressed(MouseEvent e) {
origPos = e.getPoint();
SwingUtilities.convertPointToScreen(origPos, SizeGrip.this);
}
@Override
public void mouseReleased(MouseEvent e) {
origPos = null;
}
}
}
}