Package net.yacy.visualization

Examples of net.yacy.visualization.RasterPlotter


                if (img == null) {
                    // error with image generation; send file-not-found
                    HTTPDemon.sendRespondError(conProp, out, 3, 404, "File not Found", null, null);
                } else {
                    if (img instanceof RasterPlotter) {
                        final RasterPlotter yp = (RasterPlotter) img;
                        // send an image to client
                        targetDate = new Date(System.currentTimeMillis());
                        nocache = true;
                        final String mimeType = Classification.ext2mime(targetExt, "text/html");
                        final ByteBuffer result = RasterPlotter.exportImage(yp.getImage(), targetExt);

                        // write the array to the client
                        HTTPDemon.sendRespondHeader(conProp, out, httpVersion, 200, null, mimeType, result.length(), targetDate, null, null, null, null, nocache);
                        if (!method.equals(HeaderFramework.METHOD_HEAD)) {
                            result.writeTo(out);
                        }
                    }
                    if (img instanceof EncodedImage) {
                        final EncodedImage yp = (EncodedImage) img;
                        // send an image to client
                        targetDate = new Date(System.currentTimeMillis());
                        nocache = true;
                        final String mimeType = Classification.ext2mime(targetExt, "text/html");
                        final ByteBuffer result = yp.getImage();

                        // write the array to the client
                        HTTPDemon.sendRespondHeader(conProp, out, httpVersion, 200, null, mimeType, result.length(), targetDate, null, null, null, null, nocache);
                        if (!method.equals(HeaderFramework.METHOD_HEAD)) {
                            result.writeTo(out);
View Full Code Here


        final RemoteSearch[] primarySearches = event.getPrimarySearchThreads();
        final RemoteSearch[] secondarySearches = event.getSecondarySearchThreads();
        if (primarySearches == null) return null; // this was a local search and there are no threads

        // get a copy of a recent network picture
        final RasterPlotter eventPicture = getNetworkPicture(seedDB, 120000, 640, 480, 300, 300, 9000, coronaangle, -1, Switchboard.getSwitchboard().getConfig(SwitchboardConstants.NETWORK_NAME, "unspecified"), Switchboard.getSwitchboard().getConfig("network.unit.description", "unspecified"), COL_BACKGROUND, cyc);
        //if (eventPicture instanceof ymageMatrix) eventPicture = (ymageMatrix) eventPicture; //new ymageMatrix((ymageMatrix) eventPicture);
        // TODO: fix cloning of ymageMatrix pictures

        // get dimensions
        final int cr = Math.min(eventPicture.getWidth(), eventPicture.getHeight()) / 5 - 20;
        final int cx = eventPicture.getWidth() / 2;
        final int cy = eventPicture.getHeight() / 2 + 20;

        double angle;

        // draw in the primary search peers
        for (final RemoteSearch primarySearche : primarySearches) {
            if (primarySearche == null) continue;
            eventPicture.setColor((primarySearche.isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN);
            angle = cyc + (360.0d * ((FlatWordPartitionScheme.std.dhtPosition(UTF8.getBytes(primarySearche.target().hash), null)) / DOUBLE_LONG_MAX_VALUE));
            eventPicture.arcLine(cx, cy, cr - 20, cr, angle, true, null, null, -1, -1, -1, false);
        }

        // draw in the secondary search peers
        if (secondarySearches != null) {
            for (final RemoteSearch secondarySearche : secondarySearches) {
                if (secondarySearche == null) continue;
                eventPicture.setColor((secondarySearche.isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN);
                angle = cyc + (360.0d * ((FlatWordPartitionScheme.std.dhtPosition(UTF8.getBytes(secondarySearche.target().hash), null)) / DOUBLE_LONG_MAX_VALUE));
                eventPicture.arcLine(cx, cy, cr - 10, cr, angle - 1.0, true, null, null, -1, -1, -1, false);
                eventPicture.arcLine(cx, cy, cr - 10, cr, angle + 1.0, true, null, null, -1, -1, -1, false);
            }
        }

        // draw in the search target
        final QueryParams query = event.getQuery();
        final Iterator<byte[]> i = query.queryHashes.iterator();
        eventPicture.setColor(RasterPlotter.GREY);
        while (i.hasNext()) {
            final long[] positions = seedDB.scheme.dhtPositions(i.next());
            for (final long position : positions) {
                angle = cyc + (360.0d * ((position) / DOUBLE_LONG_MAX_VALUE));
                eventPicture.arcLine(cx, cy, cr - 20, cr, angle, true, null, null, -1, -1, -1, false);
            }
        }

        return eventPicture;
    }
View Full Code Here

            final long communicationTimeout,
            final String networkName, final String networkTitle, final String color_back,
            final int cyc) {

        final RasterPlotter.DrawMode drawMode = (RasterPlotter.darkColor(color_back)) ? RasterPlotter.DrawMode.MODE_ADD : RasterPlotter.DrawMode.MODE_SUB;
        final RasterPlotter networkPicture = new RasterPlotter(width, height, drawMode, color_back);
        if (seedDB == null) return networkPicture; // no other peers known

        final int maxradius = Math.min(width, height) / 2;
        final int innerradius = maxradius * 4 / 10;
        final int outerradius = maxradius - 20;

        // draw network circle
        networkPicture.setColor(COL_DHTCIRCLE);
        networkPicture.arc(width / 2, height / 2, innerradius - 20, innerradius + 20, 100);

        //System.out.println("Seed Maximum distance is       " + yacySeed.maxDHTDistance);
        //System.out.println("Seed Minimum distance is       " + yacySeed.minDHTNumber);

        Seed seed;
        long lastseen;
        // start processes that actually draw the peers
        //final BlockingQueue<drawNetworkPicturePeerJob> drawQueue = new LinkedBlockingDeque<drawNetworkPicturePeerJob>();
        //final drawNetworkPicturePeerJob poison = new drawNetworkPicturePeerJob();
        /*
        final Thread[] drawThreads = new Thread[Runtime.getRuntime().availableProcessors()];
        for (int i = 0; i < drawThreads.length; i++) {
            drawThreads[i] = new Thread() {
                public void run() {
                    try {
                        drawNetworkPicturePeerJob job;
                        while ((job = drawQueue.take()) != poison) job.draw();
                    } catch (final InterruptedException e) {
                    }
                }
            };
            drawThreads[i].start();
        }
         */

        // draw connected senior and principals
        int count = 0;
        int totalCount = 0;
        Iterator<Seed> e = seedDB.seedsConnected(true, false, null, (float) 0.0);
        while (e.hasNext() && count < maxCount) {
            seed = e.next();
            if (seed == null) {
                Log.logWarning("NetworkGraph", "connected seed == null");
                continue;
            }
            if (seed.hash.startsWith("AD")) {//temporary patch
                continue;
            }
            //Log.logInfo("NetworkGraph", "drawing peer " + seed.getName());
            new drawNetworkPicturePeerJob(networkPicture, width / 2, height / 2, innerradius, outerradius, seed, COL_ACTIVE_DOT, COL_ACTIVE_LINE, COL_ACTIVE_TEXT, coronaangle, cyc).draw();
            count++;
        }
        totalCount += count;

        // draw disconnected senior and principals that have been seen lately
        count = 0;
        e = seedDB.seedsSortedDisconnected(false, Seed.LASTSEEN);
        while (e.hasNext() && count < maxCount) {
            seed = e.next();
            if (seed == null) {
                Log.logWarning("NetworkGraph", "disconnected seed == null");
                continue;
            }
            lastseen = Math.abs((System.currentTimeMillis() - seed.getLastSeenUTC()) / 1000 / 60);
            if (lastseen > passiveLimit) {
                break; // we have enough, this list is sorted so we don't miss anything
            }
            new drawNetworkPicturePeerJob(networkPicture, width / 2, height / 2, innerradius, outerradius, seed, COL_PASSIVE_DOT, COL_PASSIVE_LINE, COL_PASSIVE_TEXT, coronaangle, cyc).draw();
            count++;
        }
        totalCount += count;

        // draw juniors that have been seen lately
        count = 0;
        e = seedDB.seedsSortedPotential(false, Seed.LASTSEEN);
        while (e.hasNext() && count < maxCount) {
            seed = e.next();
            if (seed == null) {
                Log.logWarning("NetworkGraph", "potential seed == null");
                continue;
            }
            lastseen = Math.abs((System.currentTimeMillis() - seed.getLastSeenUTC()) / 1000 / 60);
            if (lastseen > potentialLimit) {
                break; // we have enough, this list is sorted so we don't miss anything
            }
            new drawNetworkPicturePeerJob(networkPicture, width / 2, height / 2, innerradius, outerradius, seed, COL_POTENTIAL_DOT, COL_POTENTIAL_LINE, COL_POTENTIAL_TEXT, coronaangle, cyc).draw();
            count++;
        }
        totalCount += count;

        // draw my own peer
        new drawNetworkPicturePeerJob(networkPicture, width / 2, height / 2, innerradius, outerradius, seedDB.mySeed(), COL_MYPEER_DOT, COL_MYPEER_LINE, COL_MYPEER_TEXT, coronaangle, cyc).draw();

        // signal termination
        //for (@SuppressWarnings("unused") final Thread t: drawThreads) try { drawQueue.put(poison); } catch (final InterruptedException ee) {}

        // draw DHT activity
        if (communicationTimeout >= 0) {
            final Date horizon = new Date(System.currentTimeMillis() - communicationTimeout);
            for (final Hit event: EventChannel.channels(EventChannel.DHTRECEIVE)) {
                if (event == null || event.getPubDate() == null) continue;
                if (event.getPubDate().after(horizon)) {
                    //System.out.println("*** NETWORK-DHTRECEIVE: " + event.getLink());
                    drawNetworkPictureDHT(networkPicture, width / 2, height / 2, innerradius, seedDB.mySeed(), seedDB.get(event.getLink()), COL_DHTIN, coronaangle, false, cyc);
                }
            }
            for (final Hit event: EventChannel.channels(EventChannel.DHTSEND)) {
                if (event == null || event.getPubDate() == null) continue;
                if (event.getPubDate().after(horizon)) {
                    //System.out.println("*** NETWORK-DHTSEND: " + event.getLink());
                    drawNetworkPictureDHT(networkPicture, width / 2, height / 2, innerradius, seedDB.mySeed(), seedDB.get(event.getLink()), COL_DHTOUT, coronaangle, true, cyc);
                }
            }
        }

        // draw description
        networkPicture.setColor(COL_HEADLINE);
        PrintTool.print(networkPicture, 2, 6, 0, "YACY NETWORK '" + networkName.toUpperCase() + "'", -1);
        PrintTool.print(networkPicture, 2, 14, 0, networkTitle.toUpperCase(), -1);
        PrintTool.print(networkPicture, width - 2, 6, 0, "SNAPSHOT FROM " + new Date().toString().toUpperCase(), 1);
        PrintTool.print(networkPicture, width - 2, 14, 0, "DRAWING OF " + totalCount + " SELECTED PEERS", 1);

View Full Code Here

    private static void drawBannerPicture(final int width, final int height, final String bgcolor, final String textcolor, final String bordercolor, final String name, final long links, final long words, final String type, final int ppm, final String network, final int peers, final long nlinks, final long nwords, final double nqph, final long nppm, final BufferedImage newLogo) {

        final int exprlength = 19;
        logo = newLogo;
        bannerPicture = new RasterPlotter(width, height, RasterPlotter.DrawMode.MODE_REPLACE, bgcolor);

        // draw description
        bannerPicture.setColor(textcolor);
        PrintTool.print(bannerPicture, 100, 12, 0, "PEER:  " + addTrailingBlanks(name, exprlength), -1);
        PrintTool.print(bannerPicture, 100, 22, 0, "LINKS: " + addBlanksAndDots(links, exprlength), -1);
View Full Code Here

    public static RasterPlotter respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
        final Switchboard sb = (Switchboard) env;
        final String eventID = header.get("event", SearchEventCache.lastEventID);
        if (eventID == null) return null;
        final RasterPlotter yp = NetworkGraph.getSearchEventPicture(sb.peers, eventID, 0, 0);
        if (yp == null) return new RasterPlotter(1, 1, RasterPlotter.DrawMode.MODE_SUB, "000000"); // empty image

        return yp;
    }
View Full Code Here

    public static RasterPlotter getCombinedTiles(final tileCoordinates t, int width, int height) {
        final int w = (width - 1) / 2;
        width = w * 2 + 1;
        final int h = (height - 1) / 2;
        height = h * 2 + 1;
        final RasterPlotter m = new RasterPlotter(256 * width, 256 * height, RasterPlotter.DrawMode.MODE_REPLACE, "FFFFFF");
        final List<Place> tileLoader = new ArrayList<Place>();
        Place place;
        // start tile loading concurrently
        for (int i = 0; i < width; i++) {
            for (int j = 0; j < height; j++) {
View Full Code Here

TOP

Related Classes of net.yacy.visualization.RasterPlotter

Copyright © 2018 www.massapicom. 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.