Skip to content

Commit

Permalink
SNMP-MRTG correct
Browse files Browse the repository at this point in the history
  • Loading branch information
harp077 committed Nov 6, 2022
1 parent 2c6c2e6 commit add7959
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/main/java/my/harp07/PjFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class PjFrame extends javax.swing.JFrame {
public static String currentLAF = "com.jtattoo.plaf.mint.MintLookAndFeel";
public static String currentTheme = "lib/themes/Default.theme";
public static List<String> tinyTemes = new ArrayList<>();
public static String zagolovok = "Pure Java Network Tools, v1.0.80, build 06-11-2022";
public static String zagolovok = "Pure Java Network Tools, v1.0.81, build 06-11-2022";

public PjFrame() {
initComponents();
Expand Down
54 changes: 28 additions & 26 deletions src/main/java/org/jrobin/mrtg/client/AllTraffic.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
import java.util.Date;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JScrollBar;
import javax.swing.JSeparator;
import javax.swing.JToolBar;
import javax.swing.ScrollPaneConstants;

public class AllTraffic extends javax.swing.JFrame {

public static JFrame frameAllTraffic;
private static JFrame frameAllTraffic;

private RpcClient client;
private byte[] graphBytes;
static Dimension GRAPH_SIZE = new Dimension(680, 480);

private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JToolBar jToolBar1;
private static String tip;

public AllTraffic() {
public AllTraffic(String tip) {

jPanel1 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jPanel2 = new javax.swing.JPanel();
jToolBar1 = new JToolBar();
jToolBar1.setOrientation(JToolBar.VERTICAL);
jToolBar1.setFloatable(false);
Expand All @@ -39,43 +39,45 @@ public AllTraffic() {
if (client == null) {
client = new RpcClient(mrtg.getMrtgHost());
}
graphBytes = client.getPngGraph(ri, li, new Date(System.currentTimeMillis() - 24*60*60*1000L), new Date(System.currentTimeMillis() + 1*60*60*1000L));
icon = new ImageIcon(graphBytes, "PNG graph");
/*if (icon.getIconWidth() != GRAPH_SIZE.getWidth() || icon.getIconHeight() != GRAPH_SIZE.getHeight()) {
GRAPH_SIZE = new Dimension(icon.getIconWidth(), icon.getIconHeight());
graphLabel.setPreferredSize(GRAPH_SIZE);
pack();
switch(tip) {
case "Day":
graphBytes = client.getPngGraph(ri, li, new Date(System.currentTimeMillis() - 1*24*60*60*1000L), new Date(System.currentTimeMillis() + 1*60*60*1000L));
break;
case "Week":
graphBytes = client.getPngGraph(ri, li, new Date(System.currentTimeMillis() - 7*24*60*60*1000L), new Date(System.currentTimeMillis() + 1*60*60*1000L));
break;
case "Month":
graphBytes = client.getPngGraph(ri, li, new Date(System.currentTimeMillis() - 30*24*60*60*1000L), new Date(System.currentTimeMillis() + 1*60*60*1000L));
break;
}
graphLabel.setIcon(icon);*/
icon = new ImageIcon(graphBytes, "PNG graph");
} catch (Exception e) {
Util.error(this, "Graph could not be generated:\n" + e);
}
this.jToolBar1.add(new javax.swing.JLabel(icon));
System.out.println(li.getInfo());
}
//jToolBar1.getComponents()
}
/*for (int k=1; k< 11 ; k++) {
this.jToolBar1.add(new javax.swing.JLabel("label"+k));
}*/
jScrollPane1.setViewportView(jPanel2);
jPanel1.add(jScrollPane1);
jPanel2.add(jToolBar1);
getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
jScrollPane1.setViewportView(jToolBar1);
jScrollPane1.setVerticalScrollBar(new JScrollBar());
jScrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
this.add(jScrollPane1);
pack();
}

public static void go() {
public static void go(String tip) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
frameAllTraffic = new AllTraffic();
frameAllTraffic = new AllTraffic(tip);
frameAllTraffic.setTitle(" All interfaces traffic - " + tip);
ImageIcon icone = new ImageIcon(getClass().getResource("/mrtg.png"));
frameAllTraffic.setIconImage(icone.getImage());
frameAllTraffic.setLocation(333, 333);
frameAllTraffic.setPreferredSize(GRAPH_SIZE);//.setPrefferedSize(333, 333);
frameAllTraffic.setLocation(333, 111);
//frameAllTraffic.setPreferredSize(GRAPH_SIZE);
frameAllTraffic.setSize(660, 800);
frameAllTraffic.setVisible(true);
}
});
}

}
56 changes: 51 additions & 5 deletions src/main/java/org/jrobin/mrtg/client/ClientMRTG.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ public class ClientMRTG extends JFrame {
//JMenuItem yearlyGraphItem = new JMenuItem("Yearly Graph...", KeyEvent.VK_Y);

JMenuItem customGraphItem = new JMenuItem("Custom Graph...");
JMenuItem allGraphMenuItem = new JMenuItem("All Graph...");
JMenuItem allGraphMenuItemDay = new JMenuItem("Daily all ");
JMenuItem allGraphMenuItemWeek = new JMenuItem("Weekly all ");
JMenuItem allGraphMenuItemMonth = new JMenuItem("Monthly all ");
JMenuItem allGraphMenuItemPopupDay = new JMenuItem("Daily all ");
JMenuItem allGraphMenuItemPopupWeek = new JMenuItem("Weekly all ");
JMenuItem allGraphMenuItemPopupMonth = new JMenuItem("Monthly all ");

// Help menu
JMenu helpMenu = new JMenu("Info");
Expand Down Expand Up @@ -350,13 +355,29 @@ public void actionPerformed(ActionEvent e) {
linksMenu.add(customGraphItem);
//linksMenu.setMnemonic(KeyEvent.VK_I);
linksMenu.addSeparator();
allGraphMenuItem.addActionListener(new ActionListener() {
allGraphMenuItemDay.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new Thread(()-> AllTraffic.go()).start();
//AllTraffic.go();
AllTraffic.go("Day");
//new Thread(()-> AllTraffic.go("day")).start();
}
});
linksMenu.add(allGraphMenuItem);
linksMenu.add(allGraphMenuItemDay);
//
allGraphMenuItemWeek.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
AllTraffic.go("Week");
//new Thread(()-> AllTraffic.go("day")).start();
}
});
linksMenu.add(allGraphMenuItemWeek);
//
allGraphMenuItemMonth.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
AllTraffic.go("Month");
//new Thread(()-> AllTraffic.go("day")).start();
}
});
linksMenu.add(allGraphMenuItemMonth);
menuBar.add(linksMenu);

// help menu
Expand Down Expand Up @@ -464,6 +485,31 @@ public void actionPerformed(ActionEvent e) {
removeLink();
}
});
//linksPopupMenu.addSeparator();
allGraphMenuItemPopupDay.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
AllTraffic.go("Day");
//new Thread(()-> AllTraffic.go("day")).start();
}
});
linksPopupMenu.add(allGraphMenuItemPopupDay);
//
allGraphMenuItemPopupWeek.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
AllTraffic.go("Week");
//new Thread(()-> AllTraffic.go("day")).start();
}
});
linksPopupMenu.add(allGraphMenuItemPopupWeek);
//
allGraphMenuItemPopupMonth.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
AllTraffic.go("Month");
//new Thread(()-> AllTraffic.go("day")).start();
}
});
linksPopupMenu.add(allGraphMenuItemPopupMonth);
linksPopupMenu.addSeparator();
linksPopupMenu.add(linksPopupRemoveLinkMenuItem);

MouseAdapter adapter = new MouseAdapter() {
Expand Down

0 comments on commit add7959

Please sign in to comment.