Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all 2896 articles
Browse latest View live

Visualize long texts and edit the content in Processing

$
0
0

i'm trying to recreate this poster to understand how to visualize long texts in processing. For the moment that is what i wrote:

import processing.pdf.*;

PFont f;
String txt [];
String myData [];
ArrayList romeopos = new ArrayList();
ArrayList julietpos  = new ArrayList();



void setup() {
  size(600, 800, P2D);
  background(255);
  f = createFont("Garamond", 9);
  txt=loadStrings("test.txt");


  myData = new String[txt.length];
  myData = txt[0].split(" ");
}



void draw() {
  noLoop();
  fill(50);
  textFont(f);

  for (int i=0; i<myData.length; i++) {

    if ( myData[i].toLowerCase().contains("romeo"))
      romeopos.add(i);
    if ( myData[i].toLowerCase().contains("juliet"))
      julietpos.add(i);
  }

  // text(txt[0], 10, 10, width-20, height-10);
  // println (myData);
}

i don't know how to continue, could you help me? the .txt is Romeo and Juliet written in one line.


ControlP5 and pixelated text

$
0
0

Hi. Sorry for my english. I've got a problem with my code using library ControlP5. Here you have screenshot from my app http://prntscr.com/bri6jt when using library, all words are pixelated. I tried using textMode(SCREEN), but it has been removed from Processing 2.0

G4P drop down list support

$
0
0

I have a situation where I want to use a textbox, dropdown listbox and two buttons to add, remove names from a string array. I am using g4p and the g4p builder. The g4p builder gives my a list which is stored on Quark website (thanks!) and I want people to be able to enter in new users and remove them as well.

I am a little frustrated that I do not seem to be able to access the string list directly (protected). Here is my code:

public void remove_subject_click1(GButton source, GEvent event) { //CODE:remove_subject_button:855392: println("remove_subject_button - GButton >> GEvent." + event + " @ " + millis()); name_dropList1.removeItem(name_dropList1.getSelectedIndex()); } //CODE:remove_subject_button:855392:

public void add_subject_click1(GButton source, GEvent event) { //CODE:add_subject_button:346637: println("add_subject_button - GButton >> GEvent." + event + " @ " + millis()); name_dropList1.addItem(name_textfield.getText());//.addItem(source.getText()); //name_dropList1.setItems(loadStrings("list_839008"), 0); name_dropList1.setText(name_textfield.getText()); } //CODE:add_subject_button:346637:

I want the added name to be reflected in the dropdown list immediately. Can I access the "list_839008" directly and then reload it? The drop down is created to show 3 entries but only shows 1. I have it starting with a "default" entry. I suppose that g4p could be changing the number of entries to show in the drop down list due to me only having 1 entry to begin with. I guess I could just avoid all this mess and store everything in my own file of options. But any help? Am I missing something?

Also: How can I get the number of options?

Thanks

Path Finder Program

$
0
0

Hey guys, I'm currently working on a project that is related to path finding. Right now I'm using Quarks Path Finder code as a reference and I have a question regarding this line of code "makeGraphFromBWimage(gs[graphNo], graphImage[graphNo], null, 20, 20, true);". Anyone can justify what this line of code means? Also I'm new to this processing software so any help that i can get will be much appreciated. TQ

debugging (possibly PVector/ArrayList)

$
0
0

This is a snippet of a server I'm writing that's supposed to interface with a robot, but have been bogged down by this bug..

The problem (probably?) revolves around getFinalVec() which checks if vecBuffer[] (an ArrayList of PVectors) isn't empty and is valid (not too close to a certain point). I also included computeNextVector() just in case as its called from within getFinalVec()

Assume RSol-RIst is basically (0,0,0) As far as I understand it, vecBuffer[] is acting weirdly. When I checked nextDistance (which should be a PVector close to vecBuffer.get(0) ) I found it to alternate between the correct value and a wildly different one. So even though I input 18 PVectors in to vecBuffer[] I was seeing 36, but .size() was never greater than 18. The superflous PVector would trigger (nextDistance.mag() < cullDistance) and so remove an element from vecBuffer every other pass until it was empty :(

I've only done the basics with ArrayLists and PVectors so I'm assuming that I've messed up in some really simple (but hopefully immediately recognizable) way with one of them that some one can see?

Thanks in advance.

import java.util.*;
import hypermedia.net.*;
import controlP5.*;

ArrayList<PVector> vecBuffer = new ArrayList();

//...

void draw() {
  background(0);

  if (kukaBuffer!="") {
    kukaRef = splitTokens(kukaBuffer, "=");   //load kuka data
    extractVectors();                         //extract RIst/RSol
    getFinalVec();                            //defines finalVec and ensures valid input

    extractIPOC();
    sendtoKuka();
  }
}

void getFinalVec() {
  boolean check = false;
  while (check==false) {
    if (vecBuffer.size()==0) {
      finalVec = nullVec;
      check = true;      //get out of check, null vec
    } else {
      PVector nextDistance = PVector.sub(RSol, RIst);
      nextDistance.add(vecBuffer.get(0));
      println(nextDistance);
      println("{n="+vecBuffer.size());
      println(nextDistance.mag()<cullDistance);
      if (nextDistance.mag() < cullDistance) {
        vecBuffer.remove(0);
        println("removed!!");
        check = false;   //redo check
      } else {
        finalVec = computeNewVector();
        check = true;    //get out of check, new vec
      }
    }
  }
}

PVector computeNewVector() {
  //travel vector
  PVector nextDistance = PVector.sub(RSol, RIst);
  nextDistance.add(vecBuffer.get(0));
  //println("distance: "+nextDistance.mag());
  if (nextDistance.mag() < slowLim) {
    println("reached point");
    prevVec = currVec;
    currVec = nullVec;
    vecBuffer.remove(0);
  }

  float prevScalar = prevVec.mag() - acc;
  if (prevScalar<=0) {
    prevVec = nullVec;
  } else {
    prevVec.setMag(prevScalar);
  }

  float currScalar = currVec.mag() + acc;
  currVec = vecBuffer.get(0);
  if (currScalar >= spd) {
    currVec.setMag(spd);
  } else {
    currVec.setMag(currScalar);
  }

  //println(vecBuffer.get(0));
  PVector newVec = PVector.add(currVec, prevVec);
  newVec.limit(spd);
  return newVec; //finalVec
}

Voronoi (Mesh Lib) ArrayIndexOutOfBoundsException

$
0
0

It's not the first time I'm having issues using Mesh Lib from Lee Byron. When there is a strange value of x or y, Voronoi throws ArrayIndexOutOfBoundsException.

I was able to detect when exception occurs that one particle had x value of 1.3E-44

What kind of float number is that? Is that a way to convert it back to float, or to check if it's greater/lesser than one value and constrain it before sending it to Voronoi?

Thanks!

render off frame / not on fps realtime

$
0
0

Hi, I am struggling finding a solution for this. Basically I have some animation in processing which has a duration of about 3 minutes. Final goal would be to have something like a video in HD of my animation.

I tried different methods, one is http://funprogramming.org/VideoExport-for-Processing/ which works in some way. But the bigger the quality the sooner the animation (after 1min) is getting slower and off sync to the original FPS (FrameRate) settings.

I already looked into https://vvvv.org/ which does not has a good export option either. I want to create a abstract graphics music video (different music instruments are used as input for generating different visuals).


General question: Is there a way to render animations off screen and not in realtime in processing? So that I could export my animation in high quality within a correct frame rate? Thanks a lot.

gicentre util multisketch not available

$
0
0

I want to put animations on 2 separate screens. To achieve this I decided to try the gicentre util libraray because it seemes most easy to handle for me. But despite the documentation claims that it is a part of the download package at http://www.gicentre.net/software/#/utils/ it seems that it is not. I could not found the multiSketch data in the library folder and have no idea where to find it. So import org.gicentre.utils.multisketch.*; does not function.

Does anybody know where to find that library data?


controlP5 acting up

$
0
0

Here is a simple problem, but I can't seem to figure out why the sliders won't adjust the values of the recursion. Thanks in advance.

//hexagonal fractal
import controlP5.*;
ControlP5 cp5;

int radius = 400;
int num  = 4;

void setup() {
  size(800, 800);
  background(32);
  cp5 = new ControlP5(this);

  smooth();
  noFill();
  noLoop();
  frameRate(2);

  cp5.addSlider("num")
    .setRange(0, 6)
    .setPosition(100, 100)
    .setSize(10, 100)
    .setNumberOfTickMarks(5)
    ;

  cp5.addSlider("radius")
    .setRange(150,450)
    .setPosition(0, 100)
    .setSize(10, 100)
    .setNumberOfTickMarks(5)
    ;
}

void draw() {
  translate(width/2, height/2);
  drawHexagon(radius, num);
}

void drawHexagon(float radius, int num ) {
  stroke(255);
  float x, y = 0;
  beginShape();
  for (int i = 0; i < 6; i++) {
    x = cos(radians(60*i))*radius;
    y = sin(radians(60*i))*radius;
    vertex(x, y);
  }
  endShape(CLOSE);
  //////////////////////////////////////////////////////////////

  if (num-- > 1) {

    pushMatrix();
    translate(radius/2, 0);
    drawHexagon(radius/2, num);
    popMatrix();

    pushMatrix();
    translate(-radius/4, -radius*cos(radians(30))/2);
    drawHexagon(radius/2, num);
    popMatrix();

    pushMatrix();
    translate(-radius/4, radius*cos(radians(30))/2);
    drawHexagon(radius/2, num);
    popMatrix();
  }
}

Multiple sketches

$
0
0

Howdy, i'm doing a work and I want to, by a menu with several options, click an option and a diferent sketch appears in a pop up window, i have already all the sketches done I just need to "glue" them together and i dont know how, I've tried multisketch but i don't think it lets me use more than two sketches. please help!! thanks 8)

Minim recreate waveform from FFT bins

$
0
0

So I've got a working FFT example, and a working additive synthesis example, but can someone help me connecting the dots between additive synthesis and the output of the FFT? The FFT is set to 1024 and kicks out 512 bands, for a 44.1khz signal. How should I configure the FFT output or add sines together to recreate the waveform from the FFT bins? I guess I can't get the scale right? Thank you!

.obj from Computational Geometry library?

$
0
0

I'm hoping to 3D print structures created using the Computational Geometry library by CloudLab. Is there any way to turn the structures into an .obj or .stl?

Thanks.

Installing rwmidi library issues... only.java files no .jar might be the issue

$
0
0

I downloaded the rwmidi library from github and placed the unzipped folder in my library folder but processing doesnt see it. The directory structure is different from what I normally see but saw tons of posts where people are successfully using this library.... must be something I have yet to learn how to do....

The folder is structured as follows:

rwmidi [folder]
    build.xml
    doc.sh
    README
    src [folder]
        rwdoclet [folder]
            .project
            .classpath
            src [folder]
                com [folder]
                   ruinwesen [folder]
                       doclet [folder]
                           RWDoclet.java
        rwmidi [folder]
               RWMidi.java
              (11 other .java files in this folder)

Problem with processing.net

$
0
0

I am using Processing together with an Arduino Yun. Most of the time it works fine, each even second I make measurements with the Arduino and each even minute i send a request from Processing to the Arduino to send me the mean of the last measurements. But sometimes it happens that Processing hangs.I get a "myClient" which is not "null", but a timeout! But when I make a "myClient. write" command after a "if (myClient != null)" I get directly a "NullPointerException"!

Here the important part of my code with the error message:

Main Program


297  // Get Client Anfang!
298  if((second() == 0) && (minute()%intervallMessung == 0) && !connected)
299  {
300    clientTime = true;
301    timeOut = 0;
302  }
303
304  if (clientTime) getClient();
305
306  if (connected && !sent) sendClient();

Method getClient


319  public void getClient()
320  {
321    fehler = false;
322    if (ausdruck)
323    {
324      print(nf(hour(),2) + ":" + nf(minute(),2) + ":" + nf(second(),2));
325      println(" Client Anfrage");
326    }
327    myClient = new Client(this, "192.168.2.162", 5555);
328    if (myClient != null)
329    {
330      if (ausdruck)
331      {
332        print(nf(hour(),2) + ":" + nf(minute(),2) + ":" + nf(second(),2));
333        println(" Client verbunden" + myClient);
334      }
335      connected = true;
336      clientTime = false;
337    } else {
338      if (ausdruck)
339      {
340        print(nf(hour(),2) + ":" + nf(minute(),2) + ":" + nf(second(),2));
341        println(" Client nicht verbunden : " + myClient);
342      }
343      fehler = true;
344      clientTime = false;
345    }
346  }

Output getClient


15:02:00 Client Anfrage
java.net.ConnectException: Operation timed out
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    at java.net.Socket.connect(Socket.java:528)
    at java.net.Socket.(Socket.java:425)
    at java.net.Socket.(Socket.java:208)
    at processing.net.Client.(Unknown Source)
    at Wetterstation.getClient(Wetterstation.java:327)
    at Wetterstation.draw(Wetterstation.java:304)
    at processing.core.PApplet.handleDraw(PApplet.java:2306)
    at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:243)
    at processing.core.PApplet.run(PApplet.java:2177)
    at java.lang.Thread.run(Thread.java:744)
15:03:15 Client verbunden : processing.net.Client@154c40f5

Obviously everything OK because "myClient != null" But I got an timeout message! How can I than detect an ConnectException? Normally with the "try" "Catch" method! But that doesn't work! So, because the program doesn't know anything about an exception the method sendClient is started.

method sendClient


349  public void sendClient()
350  {
351    if (timeOut < 60)
352    {
353      if (ausdruck)
354      {
355        print(nf(hour(),2) + ":" + nf(minute(),2) + ":" + nf(second(),2));
356        println(" Vor myClient.write" + myClient);
357      }
358      if ( myClient != null)
359      {
360        myClient.write("\n");
361        if (ausdruck)
362        {
363          print(nf(hour(),2) + ":" + nf(minute(),2) + ":" + nf(second(),2));
364          println(" Nach myClient.write");
365        }
366        gesendet = true;
367      } else {
368        println("NullPointer um " + nf(hour(),2) + ":" + nf(minute(),2) + ":" + nf(second(),2));
369        println("Client nicht verbunden");
370        timeOut = second();
371      }
372    } else
373    {
374      fehler = true;
375      gesendet = false;
376    }
377  }

Obviously nothing OK
myClient = null!!!! although the if statement was true!
Why is myClient null after after an if (myClient != null) statement ?


15:03:15 Vor myClient.write : processing.net.Client@154c40f5
java.lang.NullPointerException
    at processing.net.Client.write(Unknown Source)
    at processing.net.Client.write(Unknown Source)
    at Wetterstation.sendClient(Wetterstation.java:360)
    at Wetterstation.draw(Wetterstation.java:306)
    at processing.core.PApplet.handleDraw(PApplet.java:2306)
    at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:243)
    at processing.core.PApplet.run(PApplet.java:2177)
    at java.lang.Thread.run(Thread.java:744)
15:03:15 Nach myClient.write : processing.net.Client@154c40f5

Why is it not possible to detect exceptions with the "try" and "catch" method? In Java is that the normal method.

Basic question: Loading objects of another class in a class.

$
0
0

I'm not sure if I worded the title correctly, I'm still getting a grip on classes, objects, instances, etc. The below code shows what I need to do and I think I just need to change "this" to something else to fix it. I need each instance of the class to have its own copy of the video so each class can play the video independently not necessarily in sync. I get a "the constructor does not exist" error.

import processing.video.*;

Abc[] abc;

void settings()
{
  size(800, 600);
}


void setup()
{
  abc = new Abc[8];
  for (byte x = 0; x < 8; x++)
  {
    abc[x] = new Abc();
  }
}


void draw()
{
  background(0);
}


class Abc
{
  Movie _mov;

  Abc ()
  {
    _mov = new Movie(this, "C:/Users...");
  }

  void xyz()
  {
  }
}

Thanks!


Capture DSLR camera

$
0
0

I'm trying to capture video from a Nikon D90 DSLR in either default video library or GSVideo. I have the camera plugged in via USB, but Capture.list() can't find any capture devices, and the equivalent function in GSVideo returns the error: IllegalArgumentException: Element does not implement interface. Is there something I am forgetting to set on the camera itself? Can't seem to figure out. Meanwhile a typical external USB webcam works fine.

Generate Result

$
0
0

Hello Friends, I am working on checkBox array. I want to display the result for example, if i check the first checkbox from array one and the array 3 it will show me result that [11] and [31] are selected. i wanna create a true false table,

here is my code.

import g4p_controls.*;

public void setup() {
  size(480, 320, JAVA2D);
  createGUI();
  customGUI();
  // Place your setup code here
}

public void draw() {
  background(230);
}

// Use this method to add additional statements
// to customise the GUI controls
public void customGUI() {
}

public void textfield1_change1(GTextField source, GEvent event) { //CODE:txtno:852228:
} //CODE:txtno:852228:


public void button2_click2(GButton source, GEvent event) { //_CODE_:button1:882560:
  println("button1 - GButton >> GEvent." + event + " @ " + millis());
} //_CODE_:button1:882560:

public void button1_click1(GButton source, GEvent event) {  //CODE:btnSubmit:452090:
  String actant = txtno.getText();
  if (actant.isEmpty()) {
    println("increase the number of acctant");
  } else {
    int i = Integer.parseInt(txtno.getText());
    if (i > 0) {
      cbxArray = new GCheckbox[i][3];
      for (int x=0; x < i; x++) { //Actant number to display
        lblTitle = new GLabel(this, 5, 40 + 20 * x, 85, 20);
        lblTitle.setText("Actant No: "+ (x+1) + ".");
        lblTitle.setOpaque(false);
        for (int j=0; j<3; j++) {
          //For Creating checkbox
          cbxArray[x][j] = new GCheckbox(this, 105+100*j, 40 + 20 * x, 85, 20);
          cbxArray[x][j].setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
          if (j==1) {
            cbxArray[x][j].setText("Noise");
          } else if (j==2) {
            cbxArray[x][j].setText("Smell");
          } else {
            cbxArray[x][j].setText("Heat");
          }
          cbxArray[x][j].setOpaque(false);
          cbxArray[x][j].addEventHandler(this, "cbx_array_handler");
          cbxArray[x][j].tagNo = (x+1)*1000 + j + 1;
        }
      }
    }
  }
} //CODE:btnSubmit:452090:

// Create all the GUI controls. // autogenerated do not edit
public void createGUI() {
  G4P.messagesEnabled(false);
  G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
  G4P.setCursor(ARROW);
  surface.setTitle("Sketch Window");
  lblActant = new GLabel(this, 5, 5, 95, 22);
  lblActant.setText("Actant Number");
  lblActant.setTextBold();
  lblActant.setOpaque(false);
  txtno = new GTextField(this, 104, 4, 43, 30, G4P.SCROLLBARS_NONE);
  txtno.setOpaque(true);
  txtno.addEventHandler(this, "textfield1_change1");
  btnSubmit = new GButton(this, 158, 8, 80, 30);
  btnSubmit.setText("Submit");
  btnSubmit.addEventHandler(this, "button1_click1");;

G4P.messagesEnabled(false);
  G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
  G4P.setCursor(ARROW);
  surface.setTitle("Sketch Window");
  button2 = new GButton(this, 332, 278, 80, 30);
  button2.setText("Result");
  button2.addEventHandler(this, "button2_click2");


}

// Variable declarations // autogenerated do not edit
GLabel lblActant;
GTextField txtno;
GButton btnSubmit;
GLabel lblTitle;
// Create Checkbox array
GCheckbox[][] cbxArray;

public void cbx_array_handler(GCheckbox checkbox, GEvent event) {
  int actant_nbr = checkbox.tagNo / 1000;
  int cbx_nbr = checkbox.tagNo % 1000;
  print("Checkbox click for actant nbr: " + actant_nbr + "    for checkbox: ");
  switch(cbx_nbr) {
  case 1:
    print("Heat");
    break;
  case 2:
    print("Noise");
    break;
  case 3:
    print("Smell");
    break;
  default:
    print("Unknown");
  }
  println("   value: " + checkbox.isSelected());

}

GButton button2;

Thank you in advance

Help on the Efficiency of Bubble Sort Visualization

$
0
0

I recently programmed a visualization of the bubble sorting algorithm that, while works, takes a significant chunk of time and energy to run. My question is... Is there a better way to do this?

Side note, a feature I'm interested in implementing is that, whenever a swap is made, the program makes a sound (I included the library in the code)

 import processing.sound.*;
SinOsc sine;

int numOfEntries = 200;
int rectWidth;
int randomUnsortedArray[] ;
void setup()
{
  size(1000, 1000);
  background(255);
  randomUnsortedArray = new int[numOfEntries];

  rectMode(CORNERS);
  for (int i = 0; i < numOfEntries; i++)
  { //Gives each element in the array a random value
    randomUnsortedArray[i] = int(random(height));
  }
}

void draw()
{
  frameRate(120);
  randomUnsortedArray = bubbleSort(randomUnsortedArray);

  for (int i = 0; i < numOfEntries; i++)
  {
    fill(255);
    rect(i*rectWidth, height, rectWidth*(i+1), height-randomUnsortedArray[i]);
  }
}

int numOfComparisons =0;
int [] bubbleSort(int unsortedArray[])
{
  background(0);
  float rectWidth = width/unsortedArray.length;
  boolean swap;
  for (int h = 0; h < numOfEntries; h++)
  { //Redraws entire array of rectangles
    fill(255);
    rect(h*rectWidth, height, rectWidth*(h+1), height-randomUnsortedArray[h]);
  }
  swap=false;
  for (int i = 0; i < unsortedArray.length - 1; i++)
  {
    if (unsortedArray[i] > unsortedArray[i+1])
    {
      fill(90, 132, 78);
      rect(rectWidth*(i+1), height, rectWidth*(i+2), height-unsortedArray[i+1]);
      sine = new SinOsc(this);
      sine.play(); //Program eventually crashes
      //begin swap
      int temp = unsortedArray[i];
      unsortedArray[i] = unsortedArray[i+1];
      unsortedArray[i+1]= temp;
      swap = true;
      //end swap

      numOfComparisons++;
      print("Number of Comparisons: " +numOfComparisons + "\n");
      break;
    }
  }
  return unsortedArray;
}

movie = new Movie (this, "i.mov");

$
0
0

hello, i'm sorry this is a very basic question, but i'm all new in processing and trying to run a video in random jumping mode.

but it seams that i didn't knew how to install properly the video library...

please, what i have done wrong?

here is my code:

import processing.video.*;
Movie movie;

float[] cortes={
  5, 10.1, 20.7, 24.5, 32.5, 37.6, 42.8, 53.2, 55.7, 64.3, 72.3, 78,9
};

int trechoAtual;
int quantTrechos = 11;

void setup() {
  size(1020, 882);
  background(0);

  movie = new Movie (this, "komodenu.mov");
  movie.loop();
}

void movieEvent(Movie m) {
  m.read();
}

void draw() {
  if (movie.time()>cortes[trechoAtual+1]) {
    trechoAtual = int(random(quantTrechos-0.1));
    movie.jump(cortes[trechoAtual]);
  }
  image(movie, 0, 0, width, height);
}

thanks

Unfolding Maps: Can't initialize a map and set the size/position

$
0
0

Hi All,

I'm relatively new at this so please be kind, I'm sorry if this is a super dumb question.

I am trying to make a basic map using the unfolding maps library (which I intend to incorporate into another sketch once I can get it working). I have been able to get the map running at full window size, but I need to scale it down. From everything I have read this should be relatively simple- just some position and size parameters added to the initializer. However, when I do this (no matter what parameters I use) the map goes to position: 0,0 and size: 500 x 500px (approx). (see image)

Here is the code I've got:

import de.fhpotsdam.unfolding.*;
import de.fhpotsdam.unfolding.core.*;
import de.fhpotsdam.unfolding.data.*;
import de.fhpotsdam.unfolding.events.*;
import de.fhpotsdam.unfolding.geo.*;
import de.fhpotsdam.unfolding.interactions.*;
import de.fhpotsdam.unfolding.mapdisplay.*;
import de.fhpotsdam.unfolding.mapdisplay.shaders.*;
import de.fhpotsdam.unfolding.marker.*;
import de.fhpotsdam.unfolding.providers.*;
import de.fhpotsdam.unfolding.texture.*;
import de.fhpotsdam.unfolding.tiles.*;
import de.fhpotsdam.unfolding.ui.*;
import de.fhpotsdam.unfolding.utils.*;
import de.fhpotsdam.utils.*;
import de.fhpotsdam.unfolding.providers.Google;

AbstractMapProvider p1 = new Google.GoogleSimplifiedProvider();
UnfoldingMap map;

void settings() {
  size(800, 800, P2D);

  map = new UnfoldingMap(this, 100, 100, 100, 100, p1 ); //this line positions the map at 0,0 and around 500,500 size-see above image
  //map = new UnfoldingMap(this, p1 ); //this works properly but the map is full screen
}

void setup() {

  //map = new UnfoldingMap(this, p1 ); if I try to put this line here I get this error: java.lang.NoSuchFieldError:quailty (unless I removed P2D from size)
  Location melbourneLocation = new Location(-37.815924f, 144.966815f);
  float maxPanningDistance = 0.5; // in km
  map.zoomAndPanTo(15, melbourneLocation);
  map.setPanningRestriction(melbourneLocation, maxPanningDistance);
  map.setZoomRange(14, 18);
  MapUtils.createDefaultEventDispatcher(this, map);
}

void draw() {

  map.draw();
}

Any help would be amazing!

Viewing all 2896 articles
Browse latest View live