Skip to content

Commit 711dc31

Browse files
committed
create
0 parents  commit 711dc31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+5843
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target/
2+
/mrtg/

mrtg-big-logo.png

27.6 KB
Loading

mrtg.png

394 Bytes
Loading

pom.xml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>harp07</groupId>
5+
<artifactId>java-mrtg</artifactId>
6+
<version>1.0.0</version>
7+
<packaging>jar</packaging>
8+
<properties>
9+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10+
<maven.compiler.source>1.8</maven.compiler.source>
11+
<maven.compiler.target>1.8</maven.compiler.target>
12+
</properties>
13+
14+
<name>java-mrtg</name>
15+
16+
<dependencies>
17+
18+
<dependency>
19+
<groupId>jrobin</groupId>
20+
<artifactId>jrobin</artifactId>
21+
<version>1.4.0</version>
22+
</dependency>
23+
24+
<dependency>
25+
<groupId>sun-snmp</groupId>
26+
<artifactId>sun-snmp</artifactId>
27+
<version>1.3</version>
28+
</dependency>
29+
30+
<dependency>
31+
<groupId>com.jtattoo</groupId>
32+
<artifactId>JTattoo</artifactId>
33+
<version>1.6.13</version>
34+
</dependency>
35+
36+
<dependency>
37+
<groupId>commons-validator</groupId>
38+
<artifactId>commons-validator</artifactId>
39+
<version>1.7</version>
40+
</dependency>
41+
42+
</dependencies>
43+
44+
<build>
45+
46+
<finalName>java-mrtg</finalName>
47+
48+
<plugins>
49+
<!--
50+
<plugin>
51+
<artifactId>maven-resources-plugin</artifactId>
52+
<version>2.5</version>
53+
<executions>
54+
<execution>
55+
<id>copy-resources</id>
56+
<phase>install</phase>
57+
<goals>
58+
<goal>copy-resources</goal>
59+
</goals>
60+
<configuration>
61+
<outputDirectory>${basedir}/target/lib</outputDirectory>
62+
<resources>
63+
<resource>
64+
<directory>${basedir}/src/main/resources</directory>
65+
<filtering>true</filtering>
66+
</resource>
67+
</resources>
68+
</configuration>
69+
</execution>
70+
</executions>
71+
</plugin>
72+
-->
73+
<plugin>
74+
<groupId>org.apache.maven.plugins</groupId>
75+
<artifactId>maven-dependency-plugin</artifactId>
76+
<version>2.5</version>
77+
<configuration>
78+
<outputDirectory>${project.build.directory}/lib/</outputDirectory>
79+
<overWriteReleases>false</overWriteReleases>
80+
<overWriteSnapshots>false</overWriteSnapshots>
81+
<overWriteIfNewer>true</overWriteIfNewer>
82+
</configuration>
83+
<executions>
84+
<execution>
85+
<id>copy-dependencies</id>
86+
<phase>package</phase>
87+
<goals>
88+
<goal>copy-dependencies</goal>
89+
</goals>
90+
</execution>
91+
</executions>
92+
</plugin>
93+
94+
<plugin>
95+
<groupId>org.apache.maven.plugins</groupId>
96+
<artifactId>maven-jar-plugin</artifactId>
97+
<version>2.5</version>
98+
<configuration>
99+
<archive>
100+
<manifest>
101+
<addClasspath>true</addClasspath>
102+
<classpathPrefix>lib/</classpathPrefix>
103+
<classpathLayoutType>simple</classpathLayoutType>
104+
<mainClass>NewMain</mainClass>
105+
</manifest>
106+
<manifestEntries>
107+
<Version>${buildNumber}</Version>
108+
<SplashScreen-Image>pic/mrtg-big-logo.png</SplashScreen-Image>
109+
</manifestEntries>
110+
</archive>
111+
</configuration>
112+
</plugin>
113+
114+
<plugin>
115+
<artifactId>maven-compiler-plugin</artifactId>
116+
<version>2.5</version>
117+
<configuration>
118+
<source>1.8</source>
119+
<target>1.8</target>
120+
<encoding>UTF-8</encoding>
121+
</configuration>
122+
</plugin>
123+
124+
</plugins>
125+
126+
</build>
127+
128+
</project>

readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
![mrtg-big](mrtg-big-logo.png?raw=true)
2+
3+
![mrtg](mrtg.png?raw=true) Java MRTG, the traffic SNMP-poller.
4+
5+
Need JRE-1.8:
6+

readme.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Java MRTG, the traffic SNMP-poller
2+
3+
Need JRE-1.8:
4+

src/main/java/NewMain.java

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
import java.io.IOException;
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
import java.util.logging.Level;
6+
import java.util.logging.Logger;
7+
import javax.swing.ImageIcon;
8+
import javax.swing.JDialog;
9+
import javax.swing.JFrame;
10+
import javax.swing.JRootPane;
11+
import javax.swing.SwingUtilities;
12+
import javax.swing.UIDefaults;
13+
import javax.swing.UIManager;
14+
import javax.swing.UnsupportedLookAndFeelException;
15+
import org.jrobin.mrtg.client.ClientMRTG;
16+
import static org.jrobin.mrtg.client.ClientMRTG.frameClientMRTG;
17+
18+
public class NewMain {
19+
20+
public static String currentLAF = "com.jtattoo.plaf.mint.MintLookAndFeel";
21+
22+
public static void setLF() {
23+
try {
24+
UIManager.setLookAndFeel(currentLAF);
25+
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
26+
Logger.getLogger(NewMain.class.getName()).log(Level.SEVERE, null, ex);
27+
}
28+
SwingUtilities.updateComponentTreeUI(frameClientMRTG);
29+
SwingUtilities.updateComponentTreeUI(frameClientMRTG.mrtgPopupMenu);
30+
SwingUtilities.updateComponentTreeUI(frameClientMRTG.linksPopupMenu);
31+
SwingUtilities.updateComponentTreeUI(frameClientMRTG.routerPopupMenu);
32+
//frameClientMRTG.pack();
33+
//frame.setSize(FW, FH);
34+
}
35+
36+
public static void main(String[] args) {
37+
java.awt.EventQueue.invokeLater(new Runnable() {
38+
@Override
39+
public void run() {
40+
try {
41+
//FlatLightLaf.setup();
42+
//com.formdev.flatlaf.intellijthemes.FlatArcIJTheme.setup();
43+
//com.formdev.flatlaf.intellijthemes.FlatArcOrangeIJTheme.setup();
44+
//com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubIJTheme.setup();
45+
//com.formdev.flatlaf.intellijthemes.FlatHighContrastIJTheme.setup();
46+
//com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneLightIJTheme.setup();
47+
//com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneLightContrastIJTheme.setup();
48+
//InstallLF();
49+
frameClientMRTG = new ClientMRTG();
50+
ImageIcon icone = new ImageIcon(getClass().getResource("pic/mrtg.png"));
51+
frameClientMRTG.setIconImage(icone.getImage());
52+
frameClientMRTG.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
53+
JFrame.setDefaultLookAndFeelDecorated(true);
54+
JDialog.setDefaultLookAndFeelDecorated(true);
55+
frameClientMRTG.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
56+
frameClientMRTG.setSize(840, 440);
57+
frameClientMRTG.setLocation(211, 211);
58+
setLF();
59+
//frameClientMRTG.mrtgPopupMenu.updateUI();
60+
frameClientMRTG.setVisible(true);
61+
} catch (IOException ex) {
62+
Logger.getLogger(ClientMRTG.class.getName()).log(Level.SEVERE, null, ex);
63+
}
64+
}
65+
});
66+
}
67+
68+
}

src/main/java/nnm/util/ColorIcon.java

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
// Copyright (C) 2005 Mila NetWhistler. All rights reserved.
2+
// This program is free software; you can redistribute it and/or modify
3+
// it under the terms of the GNU General Public License as published by
4+
// the Free Software Foundation; either version 2 of the License, or
5+
// (at your option) any later version.
6+
//
7+
// This program is distributed in the hope that it will be useful,
8+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
// GNU General Public License for more details.
11+
//
12+
// You should have received a copy of the GNU General Public License
13+
// along with this program; if not, write to the Free Software
14+
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15+
//
16+
// For more information contact:
17+
// Mila NetWhistler <[email protected]>
18+
// http://www.netwhistler.spb.ru/
19+
//
20+
// This file from an org.jdesktop.jdnc.incubator.dleuck.icon package @author Daniel Leuck.
21+
22+
package nnm.util;
23+
24+
import java.awt.Color;
25+
import java.awt.Component;
26+
import java.awt.Dimension;
27+
import java.awt.Graphics2D;
28+
import java.awt.Image;
29+
import java.awt.RenderingHints;
30+
import java.awt.image.BufferedImage;
31+
import javax.swing.CellRendererPane;
32+
import javax.swing.Icon;
33+
import javax.swing.ImageIcon;
34+
35+
36+
public class ColorIcon {
37+
38+
private ColorIcon() {}
39+
public static Image colorize(Image icon, Color color) {
40+
Icon imageIcon = new ImageIcon(icon);
41+
BufferedImage bi=new BufferedImage(imageIcon.getIconWidth(),
42+
imageIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
43+
imageIcon.paintIcon(null, bi.createGraphics(),0,0);
44+
int iw=bi.getWidth();
45+
int ih=bi.getHeight();
46+
float[] hsb=new float[3];
47+
Color.RGBtoHSB(color.getRed(),color.getGreen(),color.getBlue(),hsb);
48+
float chue = hsb[0];
49+
for(int y=0; y<ih; y++) {
50+
for(int x=0; x<iw; x++) {
51+
int rgb=bi.getRGB(x,y);
52+
int red=(rgb >> 16) & 0xFF;
53+
int green=(rgb >> 8) & 0xFF;
54+
int blue=(rgb >> 0) & 0xFF;
55+
int alpha=(rgb >> 24) & 0xFF;
56+
Color.RGBtoHSB(red,green,blue,hsb);
57+
rgb = HSBtoRGB(chue, hsb[1], hsb[2],alpha);
58+
bi.setRGB(x,y,rgb);
59+
}
60+
}
61+
return bi;
62+
}
63+
public static ImageIcon makeIconFromComponent(Component component,
64+
int width, int height, boolean forceAntialiasing) {
65+
66+
CellRendererPane renderer= new CellRendererPane();
67+
renderer.add(component);
68+
69+
Dimension d = component.getPreferredSize();
70+
int iconWidth=(width==-1)? d.width : width;
71+
int iconHeight=(height==-1)? d.height : height;
72+
73+
BufferedImage bi=new BufferedImage(iconWidth, iconHeight,
74+
(component.isOpaque()) ? BufferedImage.TYPE_INT_RGB
75+
: BufferedImage.TYPE_INT_ARGB);
76+
77+
Graphics2D g = (Graphics2D)bi.createGraphics();
78+
79+
if(forceAntialiasing) {
80+
Object oldAA = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
81+
Object oldFM = g.getRenderingHint(
82+
RenderingHints.KEY_FRACTIONALMETRICS);
83+
Object oldRQ = g.getRenderingHint(RenderingHints.KEY_RENDERING);
84+
85+
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
86+
RenderingHints.VALUE_ANTIALIAS_ON);
87+
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
88+
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
89+
g.setRenderingHint(RenderingHints.KEY_RENDERING,
90+
RenderingHints.VALUE_RENDER_QUALITY);
91+
92+
renderer.paintComponent(g,(Component)component, null, 0, 0,
93+
iconWidth, iconHeight, true);
94+
95+
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAA);
96+
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, oldFM);
97+
g.setRenderingHint(RenderingHints.KEY_RENDERING, oldRQ);
98+
} else {
99+
renderer.paintComponent(g,(Component)component, null, 0, 0,
100+
iconWidth, iconHeight, true);
101+
}
102+
103+
return new ImageIcon(bi);
104+
}
105+
private static int HSBtoRGB(float hue, float saturation, float brightness,
106+
int alpha) {
107+
108+
int r = 0, g = 0, b = 0;
109+
if (saturation == 0) {
110+
r = g = b = (int) (brightness * 255.0f + 0.5f);
111+
} else {
112+
float h = (hue - (float)Math.floor(hue)) * 6.0f;
113+
float f = h - (float)java.lang.Math.floor(h);
114+
float p = brightness * (1.0f - saturation);
115+
float q = brightness * (1.0f - saturation * f);
116+
float t = brightness * (1.0f - (saturation * (1.0f - f)));
117+
switch ((int) h) {
118+
case 0:
119+
r = (int) (brightness * 255.0f + 0.5f);
120+
g = (int) (t * 255.0f + 0.5f);
121+
b = (int) (p * 255.0f + 0.5f);
122+
break;
123+
case 1:
124+
r = (int) (q * 255.0f + 0.5f);
125+
g = (int) (brightness * 255.0f + 0.5f);
126+
b = (int) (p * 255.0f + 0.5f);
127+
break;
128+
case 2:
129+
r = (int) (p * 255.0f + 0.5f);
130+
g = (int) (brightness * 255.0f + 0.5f);
131+
b = (int) (t * 255.0f + 0.5f);
132+
break;
133+
case 3:
134+
r = (int) (p * 255.0f + 0.5f);
135+
g = (int) (q * 255.0f + 0.5f);
136+
b = (int) (brightness * 255.0f + 0.5f);
137+
break;
138+
case 4:
139+
r = (int) (t * 255.0f + 0.5f);
140+
g = (int) (p * 255.0f + 0.5f);
141+
b = (int) (brightness * 255.0f + 0.5f);
142+
break;
143+
case 5:
144+
r = (int) (brightness * 255.0f + 0.5f);
145+
g = (int) (p * 255.0f + 0.5f);
146+
b = (int) (q * 255.0f + 0.5f);
147+
break;
148+
}
149+
}
150+
151+
return ((alpha & 0xFF) << 24) |
152+
((r & 0xFF) << 16) |
153+
((g & 0xFF) << 8) |
154+
((b & 0xFF) << 0);
155+
}
156+
157+
}

0 commit comments

Comments
 (0)