Skip to content

Commit

Permalink
Release version 0.0.1
Browse files Browse the repository at this point in the history
First public release version
  • Loading branch information
nkutsche committed Jun 14, 2017
1 parent da30661 commit 7f8de4a
Show file tree
Hide file tree
Showing 56 changed files with 8,866 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.settings/
.project
.classpath

# =========================
# Operating System Files
Expand Down
39 changes: 39 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.oxygen-plugins</groupId>
<artifactId>common-gui</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Common GUI utils</name>
<description>This project contains frequently used GUI utils, so they can be used in several projects.</description>
<dependencies>
<dependency>
<groupId>com.github.oxygen-plugins</groupId>
<artifactId>common-xml</artifactId>
<version>v0.0.1</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.3</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.github.oxygenPlugins.common.gui.borders;

import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager2;

public class ResaizeableLayout implements LayoutManager2 {

@Override
public void addLayoutComponent(String arg0, Component arg1) {
// TODO Auto-generated method stub

}

@Override
public void layoutContainer(Container arg0) {
// TODO Auto-generated method stub

}

@Override
public Dimension minimumLayoutSize(Container arg0) {
// TODO Auto-generated method stub
return null;
}

@Override
public Dimension preferredLayoutSize(Container arg0) {
// TODO Auto-generated method stub
return null;
}

@Override
public void removeLayoutComponent(Component arg0) {
// TODO Auto-generated method stub

}

@Override
public void addLayoutComponent(Component comp, Object constraints) {
// TODO Auto-generated method stub

}

@Override
public float getLayoutAlignmentX(Container target) {
// TODO Auto-generated method stub
return 0;
}

@Override
public float getLayoutAlignmentY(Container target) {
// TODO Auto-generated method stub
return 0;
}

@Override
public void invalidateLayout(Container target) {
// TODO Auto-generated method stub

}

@Override
public Dimension maximumLayoutSize(Container target) {
// TODO Auto-generated method stub
return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
package com.github.oxygenPlugins.common.gui.borders;

import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.Rectangle;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.util.ArrayList;
import java.util.HashMap;

import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

public class ResizeableAbsolutePane {
private final JPanel panel = new JPanel();
HashMap<Integer, ArrayList<ResizeableMouseListener>> compByXStart = new HashMap<Integer, ArrayList<ResizeableMouseListener>>();
HashMap<Integer, ArrayList<ResizeableMouseListener>> compByXEnd = new HashMap<Integer, ArrayList<ResizeableMouseListener>>();
HashMap<Integer, ArrayList<ResizeableMouseListener>> compByYStart = new HashMap<Integer, ArrayList<ResizeableMouseListener>>();
HashMap<Integer, ArrayList<ResizeableMouseListener>> compByYEnd = new HashMap<Integer, ArrayList<ResizeableMouseListener>>();
private Dimension panelSize;
private final ArrayList<ResizeableMouseListener> allRmls = new ArrayList<ResizeableMouseListener>();
private final int[] cols;
private final int[] rows;

public ResizeableAbsolutePane(int cols, int rows){
this.cols = new int[cols];
this.rows = new int[rows];
panel.setLayout(null);
this.panelSize = panel.getSize();
int colWidth = this.panelSize.width / cols;
int rowHeight = this.panelSize.height / rows;
for (int i = 0; i < this.cols.length; i++) {
this.cols[i] = colWidth;
}
for (int i = 0; i < this.rows.length; i++) {
this.rows[i] = rowHeight;
}
this.panel.addComponentListener(new ComponentListener() {

@Override
public void componentShown(ComponentEvent arg0) {
// TODO Auto-generated method stub

}

@Override
public void componentResized(ComponentEvent arg0) {
// Dimension size = panelSize;
panelSize = panel.getSize();
// for (ResizeableMouseListener rml : allRmls) {
//// rml.resize(size, panelSize);
// }
}

@Override
public void componentMoved(ComponentEvent arg0) {
// TODO Auto-generated method stub

}

@Override
public void componentHidden(ComponentEvent arg0) {
// TODO Auto-generated method stub

}
});
}


public void add(JComponent comp, int x, int y, int width, int height) {
makeResizeable(comp, x, y, width, height);

panel.add(comp);
comp.setBounds(getBounds(x, y, width, height));
panel.repaint();

}

private Rectangle getBounds( int x, int y, int width, int height){
int rx = 0;
int ry = 0;
int rwidth = 0;
int rheight = 0;
for (int i = 0; i < this.cols.length; i++) {
if(i < x){
rx += this.cols[i];
} else {
rwidth = this.cols[i];
}
}
for (int i = 0; i < this.rows.length; i++) {
if(i < x){
ry += this.rows[i];
} else {
rheight = this.rows[i];
}
}
Rectangle rect = new Rectangle(rx, ry, rwidth, rheight);
return rect;
}
private void makeResizeable(JComponent comp, int x, int y, int width,
int height) {
HashMap<Integer, ArrayList<ResizeableMouseListener>> oppositeNeighbours = new HashMap<Integer, ArrayList<ResizeableMouseListener>>();
oppositeNeighbours.put(SwingConstants.NORTH, ResizeableMouseListener.copy(this.compByYEnd.get(y)));
oppositeNeighbours.put(SwingConstants.SOUTH, ResizeableMouseListener.copy(this.compByYStart.get(y + height)));
oppositeNeighbours.put(SwingConstants.WEST, ResizeableMouseListener.copy(this.compByXEnd.get(x)));
oppositeNeighbours.put(SwingConstants.EAST, ResizeableMouseListener.copy(this.compByXStart.get(x + width)));
HashMap<Integer, ArrayList<ResizeableMouseListener>> inlineNeighbours = new HashMap<Integer, ArrayList<ResizeableMouseListener>>();
inlineNeighbours.put(SwingConstants.NORTH, ResizeableMouseListener.copy(this.compByYStart.get(y)));
inlineNeighbours.put(SwingConstants.SOUTH, ResizeableMouseListener.copy(this.compByYEnd.get(y + height)));
inlineNeighbours.put(SwingConstants.WEST, ResizeableMouseListener.copy(this.compByXStart.get(x)));
inlineNeighbours.put(SwingConstants.EAST, ResizeableMouseListener.copy(this.compByXEnd.get(x + width)));


ResizeableMouseListener rml = new ResizeableMouseListener(comp, 6, inlineNeighbours, oppositeNeighbours, new GridBagLayout());
this.allRmls.add(rml);
addCompToMap(rml, x, y, width, height);
}



public JPanel asJPanel(){
return this.panel;
}

private void addCompToMap(ResizeableMouseListener rml, int x, int y, int width, int height){
addCompToMap(compByXStart, rml, x);
addCompToMap(compByYStart, rml, y);
addCompToMap(compByXEnd, rml, x + width);
addCompToMap(compByYEnd, rml, y + height);

}

private void addCompToMap(HashMap<Integer, ArrayList<ResizeableMouseListener>> map, ResizeableMouseListener comp, int pos){
if(!map.containsKey(pos)){
map.put(pos, new ArrayList<ResizeableMouseListener>());
}
map.get(pos).add(comp);
}

// private class RMLPosition {
// ResizeableMouseListener rml;
// int x;
// int y;
// int w;
// int h;
// public RMLPosition(ResizeableMouseListener rml, int x, int y, int w, int h){
// this.rml = rml;
// this.x = x;
// this.y = y;
// this.w = w;
// this.h = h;
//
// }
// }
}
Loading

0 comments on commit 7f8de4a

Please sign in to comment.