Examples of HexGridPlotter


Examples of net.yacy.visualization.HexGridPlotter

        if (width > 10000) width = 10000;
        if (height < 24) height = 24;
        if (height > 10000) height = 10000;

        final RasterPlotter.DrawMode drawMode = (RasterPlotter.darkColor(color_back)) ? RasterPlotter.DrawMode.MODE_ADD : RasterPlotter.DrawMode.MODE_SUB;
        final HexGridPlotter picture = new HexGridPlotter(width, height, drawMode, color_back, cellsize);
        picture.drawGrid(color_grid);

        // calculate dimensions for left and right column
        final int gridLeft = 0;
        int gridRight = picture.gridWidth() - 2;
        if ((gridRight & 1) == 0) gridRight--;

        // draw home peer
        final int centerx = (picture.gridWidth() >> 1) - 1;
        final int centery = picture.gridHeight() >> 1;
        picture.setColor(color_dot);
        picture.gridDot(centerx, centery, 5, true, 100);
        if (corona) {
            for (int i = 0; i < 6; i++) {
                picture.gridDot(centerx, centery, 50, i * 60 + coronaangle / 6, i * 60 + 30 + coronaangle / 6);
            }
        } else {
            picture.gridDot(centerx, centery, 50, false, 100);
        }
        //picture.gridDot(centerx, centery, 31, false);
        picture.setColor(color_text);
        picture.gridPrint(centerx, centery, 5, "THIS YACY PEER", "\"" + sb.peers.myName().toUpperCase() + "\"", 0);

        // left column: collect data for access from outside
        final int verticalSlots = (picture.gridHeight() >> 1) - 1;
        final String[] hosts = new String[verticalSlots];
        final int[] time = new int[verticalSlots];
        final int[] count = new int[verticalSlots];
        for (int i = 0; i < verticalSlots; i++) {hosts[i] = null; time[i] = 0; count[i] = 0;}

        String host;
        int c, h;
        for (final int time2 : times) {
            final Iterator<String> i = sb.accessHosts();
            try {
                while (i.hasNext()) {
                    host = i.next();
                    c = sb.latestAccessCount(host, time2);
                    if (c > 0) {
                        h = (Math.abs(host.hashCode())) % hosts.length;
                        hosts[h] = host;
                        count[h] = c;
                        time[h] = time2;
                    }
                }
            } catch (final ConcurrentModificationException e) {} // we don't want to synchronize this
        }

        // draw left column: access from outside
        for (int i = 0; i < hosts.length; i++) {
            if (hosts[i] != null) {
                picture.setColor(color_dot);
                picture.gridDot(gridLeft, i * 2 + 1, 7, false, 100);
                picture.gridDot(gridLeft, i * 2 + 1, 8, false, 100);
                picture.setColor(color_text);
                picture.gridPrint(gridLeft, i * 2 + 1, 8, hosts[i].toUpperCase(), "COUNT = " + count[i] + ", TIME > " + ((time[i] >= 60000) ? ((time[i] / 60000) + " MINUTES") : ((time[i] / 1000) + " SECONDS")), -1);
                if (corona) {
                    picture.gridLine((centerx - gridLeft) / 2 - 2, i * 2 + 1, gridLeft, i * 2 + 1,
                            color_line, 100, "AAAAAA", 100, 12, 11 - coronaangle / 30, 0, true);
                    picture.gridLine(centerx, centery, (centerx - gridLeft) / 2 - 2, i * 2 + 1,
                            color_line, 100, "AAAAAA", 100, 12, 11 - coronaangle / 30, 0, true);
                } else {
                    picture.setColor(color_line);
                    picture.gridLine(gridLeft, i * 2 + 1, (centerx - gridLeft) / 2, i * 2 + 1);
                    picture.gridLine(centerx, centery, (centerx - gridLeft) / 2, i * 2 + 1);
                }
            }
        }

        // right column: collect data for access to outside
        for (int i = 0; i < verticalSlots; i++) {hosts[i] = null; time[i] = 0; count[i] = 0;}
        final Set<ConnectionInfo> allConnections = ConnectionInfo.getAllConnections();
        c = 0;
        synchronized (allConnections) {
            for (final ConnectionInfo conInfo: allConnections) {
                host = conInfo.getTargetHost();
                h = (Math.abs(host.hashCode())) % hosts.length;
                hosts[h] = host + " - " + conInfo.getCommand();
                count[h] = (int) conInfo.getUpbytes();
                time[h] = (int) conInfo.getLifetime();
            }
        }

        // draw right column: access to outside
        for (int i = 0; i < hosts.length; i++) {
            if (hosts[i] != null) {
                picture.setColor(color_dot);
                picture.gridDot(gridRight, i * 2 + 1, 7, false, 100);
                picture.gridDot(gridRight, i * 2 + 1, 8, false, 100);
                picture.setColor(color_text);
                picture.gridPrint(gridRight, i * 2 + 1, 8, hosts[i].toUpperCase(), count[i] + " BYTES, " + time[i] + " MS DUE", 1);
                if (corona) {
                    picture.gridLine(gridRight, i * 2 + 1, centerx + (gridRight - centerx) / 2 + 2, i * 2 + 1,
                            color_line, 100, "AAAAAA", 100, 12, 11 - coronaangle / 30, 0, true);
                    picture.gridLine(centerx, centery, centerx + (gridRight - centerx) / 2 + 2, i * 2 + 1,
                            color_line, 100, "AAAAAA", 100, 12, coronaangle / 30, 0, true);
                } else {
                    picture.setColor(color_line);
                    picture.gridLine(gridRight, i * 2 + 1, centerx + (gridRight - centerx) / 2, i * 2 + 1);
                    picture.gridLine(centerx, centery, centerx + (gridRight - centerx) / 2, i * 2 + 1);
                }
            }
        }

        // print headline
        picture.setColor(color_text);
        PrintTool.print(picture, 2, 6, 0, "YACY NODE ACCESS GRID", -1);
        PrintTool.print(picture, width - 2, 6, 0, "SNAPSHOT FROM " + new Date().toString().toUpperCase(), 1);

        // print legend
        picture.setColor(color_grid);
        picture.gridLine(gridLeft, 0, centerx - 3, 0);
        picture.gridLine(gridLeft, 0, gridLeft, picture.gridHeight() - 1);
        picture.gridLine(centerx - 3, 0, centerx - 3, picture.gridHeight() - 1);
        picture.setColor(color_dot);
        picture.gridLine(gridLeft, picture.gridHeight() - 1, centerx - 3, picture.gridHeight() - 1);
        picture.gridPrint(gridLeft, picture.gridHeight() - 1, 8, "", "INCOMING CONNECTIONS", -1);

        picture.setColor(color_grid);
        picture.gridLine(centerx + 3, 0, gridRight, 0);
        picture.gridLine(centerx + 3, 0, centerx + 3, picture.gridHeight() - 1);
        picture.gridLine(gridRight, 0, gridRight, picture.gridHeight() - 1);
        picture.setColor(color_dot);
        picture.gridLine(centerx + 3, picture.gridHeight() - 1, gridRight, picture.gridHeight() - 1);
        picture.gridPrint(gridRight, picture.gridHeight() - 1, 8, "", "OUTGOING CONNECTIONS", 1);

        return picture;

    }
View Full Code Here

Examples of net.yacy.visualization.HexGridPlotter

        if (width > 10000) width = 10000;
        if (height < 24) height = 24;
        if (height > 10000) height = 10000;

        final RasterPlotter.DrawMode drawMode = (RasterPlotter.darkColor(color_back)) ? RasterPlotter.DrawMode.MODE_ADD : RasterPlotter.DrawMode.MODE_SUB;
        final HexGridPlotter picture = new HexGridPlotter(width, height, drawMode, color_back, cellsize);
        picture.drawGrid(color_grid);

        // calculate dimensions for left and right column
        final int gridLeft = 0;
        int gridRight = picture.gridWidth() - 2;
        if ((gridRight & 1) == 0) gridRight--;

        // draw home peer
        final int centerx = (picture.gridWidth() >> 1) - 1;
        final int centery = picture.gridHeight() >> 1;
        picture.setColor(color_dot);
        picture.gridDot(centerx, centery, 5, true, 100);
        if (corona) {
            for (int i = 0; i < 6; i++) {
                picture.gridDot(centerx, centery, 50, i * 60 + coronaangle / 6, i * 60 + 30 + coronaangle / 6);
            }
        } else {
            picture.gridDot(centerx, centery, 50, false, 100);
        }
        //picture.gridDot(centerx, centery, 31, false);
        picture.setColor(color_text);
        picture.gridPrint(centerx, centery, 5, "THIS YACY PEER", "\"" + sb.peers.myName().toUpperCase() + "\"", 0);

        // left column: collect data for access from outside
        final int verticalSlots = (picture.gridHeight() >> 1) - 1;
        final String[] hosts = new String[verticalSlots];
        final int[] time = new int[verticalSlots];
        final int[] count = new int[verticalSlots];
        for (int i = 0; i < verticalSlots; i++) {hosts[i] = null; time[i] = 0; count[i] = 0;}

        String host;
        int c, h;
        for (final int time2 : times) {
            final Iterator<String> i = sb.accessHosts();
            try {
                while (i.hasNext()) {
                    host = i.next();
                    c = sb.latestAccessCount(host, time2);
                    if (c > 0) {
                        h = (Math.abs(host.hashCode())) % hosts.length;
                        hosts[h] = host;
                        count[h] = c;
                        time[h] = time2;
                    }
                }
            } catch (final ConcurrentModificationException e) {} // we don't want to synchronize this
        }

        // draw left column: access from outside
        for (int i = 0; i < hosts.length; i++) {
            if (hosts[i] != null) {
                picture.setColor(color_dot);
                picture.gridDot(gridLeft, i * 2 + 1, 7, false, 100);
                picture.gridDot(gridLeft, i * 2 + 1, 8, false, 100);
                picture.setColor(color_text);
                picture.gridPrint(gridLeft, i * 2 + 1, 8, hosts[i].toUpperCase(), "COUNT = " + count[i] + ", TIME > " + ((time[i] >= 60000) ? ((time[i] / 60000) + " MINUTES") : ((time[i] / 1000) + " SECONDS")), -1);
                if (corona) {
                    picture.gridLine((centerx - gridLeft) / 2 - 2, i * 2 + 1, gridLeft, i * 2 + 1,
                            color_line, 100, "AAAAAA", 100, 12, 11 - coronaangle / 30, 0, true);
                    picture.gridLine(centerx, centery, (centerx - gridLeft) / 2 - 2, i * 2 + 1,
                            color_line, 100, "AAAAAA", 100, 12, 11 - coronaangle / 30, 0, true);
                } else {
                    picture.setColor(color_line);
                    picture.gridLine(gridLeft, i * 2 + 1, (centerx - gridLeft) / 2, i * 2 + 1);
                    picture.gridLine(centerx, centery, (centerx - gridLeft) / 2, i * 2 + 1);
                }
            }
        }

        // right column: collect data for access to outside
        for (int i = 0; i < verticalSlots; i++) {hosts[i] = null; time[i] = 0; count[i] = 0;}
        final Set<ConnectionInfo> allConnections = ConnectionInfo.getAllConnections();
        c = 0;
        synchronized (allConnections) {
            for (final ConnectionInfo conInfo: allConnections) {
                host = conInfo.getTargetHost();
                h = (Math.abs(host.hashCode())) % hosts.length;
                hosts[h] = host + " - " + conInfo.getCommand();
                count[h] = (int) conInfo.getUpbytes();
                time[h] = (int) conInfo.getLifetime();
            }
        }

        // draw right column: access to outside
        for (int i = 0; i < hosts.length; i++) {
            if (hosts[i] != null) {
                picture.setColor(color_dot);
                picture.gridDot(gridRight, i * 2 + 1, 7, false, 100);
                picture.gridDot(gridRight, i * 2 + 1, 8, false, 100);
                picture.setColor(color_text);
                picture.gridPrint(gridRight, i * 2 + 1, 8, hosts[i].toUpperCase(), count[i] + " BYTES, " + time[i] + " MS DUE", 1);
                if (corona) {
                    picture.gridLine(gridRight, i * 2 + 1, centerx + (gridRight - centerx) / 2 + 2, i * 2 + 1,
                            color_line, 100, "AAAAAA", 100, 12, 11 - coronaangle / 30, 0, true);
                    picture.gridLine(centerx, centery, centerx + (gridRight - centerx) / 2 + 2, i * 2 + 1,
                            color_line, 100, "AAAAAA", 100, 12, coronaangle / 30, 0, true);
                } else {
                    picture.setColor(color_line);
                    picture.gridLine(gridRight, i * 2 + 1, centerx + (gridRight - centerx) / 2, i * 2 + 1);
                    picture.gridLine(centerx, centery, centerx + (gridRight - centerx) / 2, i * 2 + 1);
                }
            }
        }

        // print headline
        picture.setColor(color_text);
        PrintTool.print(picture, 2, 6, 0, "YACY NODE ACCESS GRID", -1);
        PrintTool.print(picture, width - 2, 6, 0, "SNAPSHOT FROM " + new Date().toString().toUpperCase(), 1);

        // print legend
        picture.setColor(color_grid);
        picture.gridLine(gridLeft, 0, centerx - 3, 0);
        picture.gridLine(gridLeft, 0, gridLeft, picture.gridHeight() - 1);
        picture.gridLine(centerx - 3, 0, centerx - 3, picture.gridHeight() - 1);
        picture.setColor(color_dot);
        picture.gridLine(gridLeft, picture.gridHeight() - 1, centerx - 3, picture.gridHeight() - 1);
        picture.gridPrint(gridLeft, picture.gridHeight() - 1, 8, "", "INCOMING CONNECTIONS", -1);

        picture.setColor(color_grid);
        picture.gridLine(centerx + 3, 0, gridRight, 0);
        picture.gridLine(centerx + 3, 0, centerx + 3, picture.gridHeight() - 1);
        picture.gridLine(gridRight, 0, gridRight, picture.gridHeight() - 1);
        picture.setColor(color_dot);
        picture.gridLine(centerx + 3, picture.gridHeight() - 1, gridRight, picture.gridHeight() - 1);
        picture.gridPrint(gridRight, picture.gridHeight() - 1, 8, "", "OUTGOING CONNECTIONS", 1);

        return picture;

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.