예제 #1
0
 /**
  * Remove the specified zone from the zone picker
  *
  * @param zone the zone to remove
  * @return The zone that was removed
  */
 public Zone remove(Zone zone) {
   Color color = zone.getPickColor();
   int pixelColor = color.getAlpha() + (color.getRGB() << 8);
   Zone removed = zoneMap.remove(pixelColor);
   zone.setPickColor(null);
   return removed;
 }
예제 #2
0
  RRsetIterator(Zone zone, DomainFactory factory) {

    this.zone = zone;
    this.factory = factory;
    this.domainIter = zone.iterator();
    if (domainIter == null) {
      throw new RuntimeException("Null Domain iterator");
    }

    String rootString = zone.getRootDomain();
    this.originNode = getDomainResource(rootString);

    if (originNode.getRRset(Type.SOA) == null) {
      throw new RuntimeException("Zone " + rootString + " missing SOA record");
    }
    if (originNode.getRRset(Type.NS) == null) {
      throw new RuntimeException("Zone " + rootString + " missing NS rrset");
    }

    List<RRset> sets = originNode.getAllRRsets();
    this.current = new RRset[sets.size()];
    for (int j = 2, k = 0; k < sets.size(); k++) {
      RRset rrset = sets.get(k);
      int type = rrset.getType();

      if (type == Type.SOA) {
        current[0] = rrset;
      } else if (type == Type.NS) {
        current[1] = rrset;
      } else {
        current[j++] = rrset;
      }
    }
  }
예제 #3
0
  /**
   * Add a zone to the zone picker.
   *
   * @param zone the zone to enable picking on.
   */
  public void add(Zone zone) {
    // check if we already have this zone
    if (zoneMap.containsValue(zone)) return;

    if (zoneMap.size() == POSSIBLE_COLORS) {
      // We've run out of pick colours :( oh no
      System.err.printf(
          "The number of zones has exceeded the maximum number of pickable zones (%d). This recently added zone (%s) will not be pickable.",
          POSSIBLE_COLORS, zone);
      return;
    }

    // get a new colour
    zone.setPickColor(new Color(currentColor, false));
    int pixelColor = 0xff + (currentColor << 8);
    zoneMap.put(pixelColor, zone);

    // dont bother searching if we're out of colours anyways
    if (zoneMap.size() < POSSIBLE_COLORS) {
      while (zoneMap.containsKey(pixelColor)) {
        currentColor += 1;
        pixelColor = 0xff + (currentColor << 8);
      }
    }

    // add all of the zone's child zones
    for (Zone child : zone.getChildren()) this.add(child);
  }
  /**
   * Creates a new oscillator from a preset in a SoundFont file.
   *
   * @param frequency - The frequency determines what key was pressed.
   * @parma preset - The SoundFont preset to get the sample data from.
   * @param sampleRateInHz - The sample rate of the output synthesizer.
   */
  public SoundFontOscillator(FrequencyProvider frequency, Preset preset, double sampleRateInHz) {
    super(frequency);
    logger_ = Logger.getLogger(getClass().getName());
    preset_ = preset;
    sampleRateInHz_ = sampleRateInHz;

    // Find the max sample length.
    maxSampleLength_ = 1;
    for (Zone pzone : preset_.getZoneList()) {
      Instrument instrument = pzone.getInstrument();
      if (instrument != null) {
        for (Zone izone : instrument.getZoneList()) {
          Sample sample = izone.getSample();
          int length = (int) Math.ceil((sampleRateInHz_ * izone.getCount()) / sample.getRate());
          if (length > maxSampleLength_) {
            maxSampleLength_ = length;
          }
        }
      }
    }

    currentSample_ = null;
    currentSampleIndex_ = 0;

    buffer_ = new double[maxSampleLength_];
    Arrays.fill(buffer_, 0.0);
    bufferIndex_ = 0;
  }
예제 #5
0
  private void draw() {

    this.image.clear();

    if (this.viewport == null || zones == null) return;

    for (Zone zone : zones) {

      // Zones only have ONE animation currently so no need to check the type

      int diff = 1;
      if (zone.zone() == Stadium.TYPE_ID) {
        diff = 2;
      }
      this.image.drawImage(
          AnimationLayer.NOPOWER_IMG,
          (((zone.origin().x + diff) * Tile.SIZE) - viewport.x),
          (((zone.origin().y - diff) * Tile.SIZE) - viewport.y));
    }

    /*
    for (Iterator it = tiles.keySet().iterator(); it.hasNext();) {
    Tile tile = (Tile)it.next();
    this.image.drawImage(tile.nextFrame(), ((tile.position().x * Tile.SIZE) - viewport.x), ((tile.position().y * Tile.SIZE) - viewport.y));
    }
     */

    needsUpdate = false;
  }
예제 #6
0
 private static void drawEventsHod(SvgFile svg, List<UserData> users, Map<Integer, Zone> zones) {
   float strokeWidth = 0.5f;
   int ci = 0;
   for (UserData user : users) {
     for (Event e : user.getEvents()) {
       //				e.get
       Float hod = e.getHourOfDay();
       if (hod == null) continue;
       String stroke = getColour(scaleHod(hod));
       if (e.getGpsTagId() != 0) {
         Zone z = zones.get(e.getGpsTagId());
         if (z != null) {
           String fill = getZoneFill(z);
           float rx = (float) ((Math.random() - 0.5) * JITTER);
           float ry = (float) ((Math.random() - 0.5) * JITTER);
           float size = scaleD(z.getRadius());
           if (size < 1) size = 1;
           svg.circle(
               rx + scaleX(Mercator.mercX(z.getLon())),
               ry + scaleY(Mercator.mercY(z.getLat())),
               size,
               stroke,
               1.0f,
               fill,
               "fill-opacity=\"0.1\"");
         }
       }
     }
   }
 }
예제 #7
0
  /**
   * Get the Zone under the specified coordinates.
   *
   * @param x x coordinate of the specified pixel
   * @param y y coordinate of the specified pixel
   * @return If there is a Zone at the specified coordinates, that zone, otherwise null.
   */
  public Zone pick(int x, int y) {
    // clamp x and y
    if (y >= picking_context.height) y = picking_context.height - 1;
    if (x >= picking_context.width) x = picking_context.width - 1;
    if (y < 0) y = 0;
    if (x < 0) x = 0;

    PGL pgl = picking_context.beginPGL();
    int pixel;
    // force fallback until 2.0b10
    if (!SMT.fastPickingEnabled() || pgl == null) {
      // really slow way(max 70 fps on a high end card vs 200+ fps with readPixels), with loadPixels
      // at the end of render()
      pixel = picking_context.pixels[x + y * picking_context.width];
    } else {
      buffer.clear();
      pgl.readPixels(x, picking_context.height - y, 1, 1, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, buffer);
      pixel = buffer.getInt();
    }
    picking_context.endPGL();

    if (zoneMap.containsKey(pixel)) {
      // if mapped it is either a Zone or null (background)
      Zone picked = zoneMap.get(pixel);
      Zone current = picked;
      while (current != null) {
        if (current.stealChildrensTouch) return current;
        current = current.getParent();
      }
      return picked;
    } else return null;
  }
예제 #8
0
 @Test
 public void toJson() {
   Zone zone = new Zone();
   zone.addLastUserAction(new UserAction(null, null, null, null, UpdateAction.UPDATE_ZONE));
   String json = GsonUtil.objectToJson(zone);
   assertTrue(json.contains(UpdateAction.UPDATE_ZONE.toString()));
 }
예제 #9
0
 private static void drawEvents(
     SvgFile svg, List<UserData> users, String overrideStroke, Map<Integer, Zone> zones) {
   float strokeWidth = 0.5f;
   int ci = 0;
   for (UserData user : users) {
     ci = ci + 1 % colors.length;
     String stroke = overrideStroke != null ? overrideStroke : colors[ci];
     for (Event e : user.getEvents()) {
       //				e.get
       if (e.getGpsTagId() != 0) {
         Zone z = zones.get(e.getGpsTagId());
         if (z != null) {
           String fill = getZoneFill(z);
           float rx = (float) ((Math.random() - 0.5) * JITTER);
           float ry = (float) ((Math.random() - 0.5) * JITTER);
           svg.circle(
               rx + scaleX(Mercator.mercX(z.getLon())),
               ry + scaleY(Mercator.mercY(z.getLat())),
               scaleD(z.getRadius()),
               stroke,
               1.0f,
               fill,
               "fill-opacity=\"0.1\"");
         }
       }
     }
   }
 }
예제 #10
0
파일: Database.java 프로젝트: Meaglin/Zones
 public List<Vertice> get(Zone zone) {
   Connection conn = null;
   PreparedStatement st = null;
   ResultSet rs = null;
   List<Vertice> vertices = new ArrayList<Vertice>();
   try {
     conn = getConnection();
     st = conn.prepareStatement(SELECT_VERTICE);
     st.setInt(1, zone.getId());
     rs = st.executeQuery();
     while (rs.next()) {
       Vertice v = new Vertice();
       v.setId(rs.getInt(1));
       v.setVertexorder(rs.getInt(2));
       v.setX(rs.getInt(3));
       v.setZ(rs.getInt(4));
       vertices.add(v);
     }
   } catch (Exception e) {
     Zones.log.warning(
         "[Zones]Error loading vertices of " + zone.getName() + "[" + zone.getId() + "] :");
     e.printStackTrace();
   } finally {
     try {
       if (conn != null) conn.close();
       if (st != null) st.close();
       if (rs != null) rs.close();
     } catch (Exception e) {
     }
   }
   return vertices;
 }
예제 #11
0
  @Test(enabled = true)
  public void testRegisterTemplate() throws Exception {
    Zone zone = Iterables.getFirst(client.getZoneClient().listZones(), null);
    assertNotNull(zone);
    Iterable<Network> networks =
        client
            .getNetworkClient()
            .listNetworks(ListNetworksOptions.Builder.zoneId(zone.getId()).isDefault(true));
    networks =
        Iterables.filter(
            networks,
            new Predicate<Network>() {
              @Override
              public boolean apply(@Nullable Network network) {
                return network != null && network.getState().equals("Implemented");
              }
            });
    assertEquals(Iterables.size(networks), 1);
    Network network = Iterables.getOnlyElement(networks, null);
    assertNotNull(network);
    Set<OSType> osTypes = client.getGuestOSClient().listOSTypes();
    OSType osType = Iterables.getFirst(osTypes, null);

    // Register a template
    RegisterTemplateOptions options = RegisterTemplateOptions.Builder.bits(32).isExtractable(true);
    TemplateMetadata templateMetadata =
        TemplateMetadata.builder()
            .name(prefix + "-registerTemplate")
            .osTypeId(osType.getId())
            .displayText("jclouds live testRegisterTemplate")
            .build();
    Set<Template> templates =
        client
            .getTemplateClient()
            .registerTemplate(
                templateMetadata, "VHD", "XenServer", IMPORT_VHD_URL, zone.getId(), options);
    registeredTemplate = Iterables.getOnlyElement(templates, null);
    assertNotNull(registeredTemplate);

    // Ensure it is available
    final long zoneId = zone.getId();
    Predicate<Template> templateReadyPredicate =
        new Predicate<Template>() {
          @Override
          public boolean apply(@Nullable Template template) {
            if (template == null) return false;
            Template t2 = client.getTemplateClient().getTemplateInZone(template.getId(), zoneId);
            Logger.CONSOLE.info("%s", t2.getStatus());
            return "Download Complete".equals(t2.getStatus());
          }
        };
    assertTrue(
        new RetryablePredicate<Template>(templateReadyPredicate, 60000).apply(registeredTemplate));

    // Create a VM that uses this template
    vmForRegistration =
        VirtualMachineClientLiveTest.createVirtualMachineInNetwork(
            network, registeredTemplate.getId(), client, jobComplete, virtualMachineRunning);
    assertNotNull(vmForRegistration);
  }
예제 #12
0
 @Test
 public void sameActionTwice() {
   Zone zone = new Zone();
   zone.addLastUserAction(new UserAction(null, null, null, null, UpdateAction.UPDATE_ZONE));
   zone.addLastUserAction(new UserAction(null, null, null, null, UpdateAction.UPDATE_ZONE));
   assertEquals(1, zone.getLastUserActions().size());
 }
예제 #13
0
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onPistonExtend(BlockPistonExtendEvent event) {
   ZoneManager manager = m_plugin.getZoneManager();
   if (!manager.zoneExists(event.getBlock().getLocation())) {
     for (Block b : event.getBlocks()) {
       if (manager.zoneExists(b.getLocation())) {
         event.setCancelled(true);
         return;
       } else if (manager.zoneExists(b.getRelative(event.getDirection()).getLocation())) {
         event.setCancelled(true);
         return;
       }
     }
   } else {
     Zone zone = manager.getZone(event.getBlock().getLocation());
     for (Block b : event.getBlocks()) {
       if (manager.zoneExists(b.getLocation())) {
         if (!zone.getName().equals(manager.getZone(b.getLocation()).getName())) {
           event.setCancelled(true);
           return;
         }
       }
     }
   }
 }
예제 #14
0
 @Test
 public void multipleActions() {
   Zone zone = new Zone();
   zone.addLastUserAction(new UserAction(null, null, null, null, UpdateAction.UPDATE_ZONE));
   zone.addLastUserAction(new UserAction(null, null, null, null, UpdateAction.SAVE_ZOMBIES));
   zone.addLastUserAction(new UserAction(null, null, null, null, UpdateAction.SAVE_PEEK));
   assertEquals(3, zone.getLastUserActions().size());
 }
예제 #15
0
  public void defTerri(Zone p, int i, Image img) {
    List<Coordonnees> temp = new ArrayList<Coordonnees>();
    temp = game.getZone(new Coordonnees(p.getX(), p.getY()), i);

    for (Coordonnees c : temp) {
      panelPere.getListTerri().add(new Zone(c.getX(), c.getY(), img));
    }
  }
예제 #16
0
 /**
  * @param z
  * @return
  */
 public static String getZoneFill(Zone z) {
   String fill = "#000";
   if ("photo opportunity".equals(z.getType())) fill = "#00f";
   else if ("lunch/break".equals(z.getType())) fill = "#0f0";
   else if ("Q-Zone".equals(z.getType())) fill = "#f00";
   else if ("end of ride".equals(z.getType())) fill = "#ff0";
   return fill;
 }
예제 #17
0
  @Test(enabled = true)
  public void testCreateTemplate() throws Exception {
    Zone zone = Iterables.getFirst(client.getZoneClient().listZones(), null);
    assertNotNull(zone);
    Iterable<Network> networks =
        client
            .getNetworkClient()
            .listNetworks(ListNetworksOptions.Builder.zoneId(zone.getId()).isDefault(true));
    networks =
        Iterables.filter(
            networks,
            new Predicate<Network>() {
              @Override
              public boolean apply(@Nullable Network network) {
                return network != null && network.getState().equals("Implemented");
              }
            });
    assertEquals(Iterables.size(networks), 1);
    Network network = Iterables.getOnlyElement(networks, null);
    assertNotNull(network);

    // Create a VM and stop it
    Long templateId = (imageId != null && !"".equals(imageId)) ? new Long(imageId) : null;
    vmForCreation =
        VirtualMachineClientLiveTest.createVirtualMachineInNetwork(
            network, templateId, client, jobComplete, virtualMachineRunning);
    assertTrue(
        jobComplete.apply(
            client.getVirtualMachineClient().stopVirtualMachine(vmForCreation.getId())),
        vmForCreation.toString());

    // Work out the VM's volume
    Set<Volume> volumes =
        client
            .getVolumeClient()
            .listVolumes(ListVolumesOptions.Builder.virtualMachineId(vmForCreation.getId()));
    assertEquals(volumes.size(), 1);
    Volume volume = Iterables.getOnlyElement(volumes);

    // Create a template
    CreateTemplateOptions options = CreateTemplateOptions.Builder.volumeId(volume.getId());
    AsyncCreateResponse response =
        client
            .getTemplateClient()
            .createTemplate(
                TemplateMetadata.builder()
                    .name(prefix + "-createTemplate")
                    .osTypeId(vmForCreation.getGuestOSId())
                    .displayText("jclouds live testCreateTemplate")
                    .build(),
                options);
    assertTrue(jobComplete.apply(response.getJobId()), vmForCreation.toString());
    createdTemplate =
        client.getTemplateClient().getTemplateInZone(response.getId(), vmForCreation.getZoneId());

    // Assertions
    assertNotNull(createdTemplate);
  }
  public void parseDataFile(BufferedReader in) throws IOException {
    Zone zone = null;
    String line;
    while ((line = in.readLine()) != null) {
      String trimmed = line.trim();
      if (trimmed.length() == 0 || trimmed.charAt(0) == '#') {
        continue;
      }

      int index = line.indexOf('#');
      if (index >= 0) {
        line = line.substring(0, index);
      }

      // System.out.println(line);

      StringTokenizer st = new StringTokenizer(line, " \t");

      if (Character.isWhitespace(line.charAt(0)) && st.hasMoreTokens()) {
        if (zone != null) {
          // Zone continuation
          zone.chain(st);
        }
        continue;
      } else {
        if (zone != null) {
          iZones.add(zone);
        }
        zone = null;
      }

      if (st.hasMoreTokens()) {
        String token = st.nextToken();
        if (token.equalsIgnoreCase("Rule")) {
          Rule r = new Rule(st);
          RuleSet rs = iRuleSets.get(r.iName);
          if (rs == null) {
            rs = new RuleSet(r);
            iRuleSets.put(r.iName, rs);
          } else {
            rs.addRule(r);
          }
        } else if (token.equalsIgnoreCase("Zone")) {
          zone = new Zone(st);
        } else if (token.equalsIgnoreCase("Link")) {
          iLinks.add(st.nextToken());
          iLinks.add(st.nextToken());
        } else {
          System.out.println("Unknown line: " + line);
        }
      }
    }

    if (zone != null) {
      iZones.add(zone);
    }
  }
예제 #19
0
  @Override
  public void mouseClicked(MouseEvent e) {
    Point p = new Point(Paint.pxtoHex(e.getX(), e.getY()));
    if (verifPresence(p.x, p.y) == 1) {
      panelPere.getListDeplacement().clear();
      panelPere.repaint();
      for (Troupes z : getListUnit()) {
        if (z.getCo().getX() == p.x && z.getCo().getY() == p.y) {
          this.SelectionTemp = z;
          panelPere.afficherDeplacement(z);
          panelPere.repaint();
        }
      }
    } else if (verifPresence(p.x, p.y) == 2) {
      afficherOptionVille();
    } else if ((verifPresence(p.x, p.y) == 0) && SelectionTemp != null) {
      for (Zone z : panelPere.getListDeplacement()) {
        if (z.getX() == p.x && z.getY() == p.y) {
          for (Troupes t : getListUnit()) {
            if (t.getCo().getX() == SelectionTemp.getCo().getX()
                && t.getCo().getY() == SelectionTemp.getCo().getY()) {
              t.getCo().setX(p.x);
              t.getCo().setY(p.y);
              repaint();
            }
          }
        }
      }
      panelPere.getListDeplacement().clear();
      panelPere.repaint();
      SelectionTemp = null;
    } else if ((verifPresence(p.x, p.y) == 0) && SelectionTemp == null) {
      panelPere.getListDeplacement().clear();
      panelPere.repaint();
      if (verifCarte(p.x, p.y)) {
        addUnit(p.x, p.y);
      }
    }

    if (!(e.getX() < 30
        || e.getY() < 30
        || e.getX() >= f.getWidth()
        || e.getY() >= f.getHeight())) {
      Image img;
      try {
        img = ImageIO.read(new File("./ressources/images/unit/SelectorYellow.png"));
        Zone z = new Zone(p.x, p.y, img);
        panelPere.setSelect(z);
      } catch (IOException e1) {
        e1.printStackTrace();
      }
      panelPere.repaint();
    }
  }
예제 #20
0
 @Test
 public void buildingInZone() throws JAXBException {
   String xml =
       "<zone x=\"14\" y=\"15\" nvt=\"0\" danger=\"3\">"
           + "<building name=\"Disused Car Park\" type=\"14\" dig=\"0\">An almost completely buried underground parking lot. An ideal venue to 'go quietly into the night' as long as nobody hears you...</building>"
           + "</zone>";
   Zone zone = (Zone) XmlToObjectConverter.convertXmlToObject(xml, Zone.class);
   assertNotNull("Expected a building to be inside the zone", zone.getBuilding());
   assertEquals(14, zone.getBuilding().getType());
   assertEquals(0, zone.getBuilding().getDig());
 }
예제 #21
0
  private void analyse(double x, double y) {
    StringBuffer buf = new StringBuffer();

    List<Zone> zones = getShot().getZones(x, y);

    if (zones.size() > 0) {
      for (Zone zone : zones) {
        buf.append(zone.toString() + "\n");
      }
    }

    lblInfo.setText(buf.toString());
  }
예제 #22
0
 private static void drawZones2(SvgFile svg, Map<Integer, Zone> zones) {
   for (Zone z : zones.values()) {
     String fill = getZoneFill(z);
     float size = scaleD(z.getRadius());
     if (size < 1) size = 1;
     svg.circle(
         scaleX(Mercator.mercX(z.getLon())),
         scaleY(Mercator.mercY(z.getLat())),
         size,
         fill,
         0.0f,
         fill,
         " fill-opacity=\"15%\" stroke-opacity=\"20%\"");
   }
 }
예제 #23
0
  /**
   * Generates aliases and rawOffsets tables.
   *
   * @param zi a Zoneinfo containing Zones
   */
  void add(Zoneinfo zi) {
    Map<String, Zone> zones = zi.getZones();

    for (String zoneName : zones.keySet()) {
      Zone zone = zones.get(zoneName);
      String zonename = zone.getName();
      int rawOffset = zone.get(zone.size() - 1).getGmtOffset();

      // If the GMT offset of this Zone will change in some
      // future time, this Zone is added to the exclude list.
      boolean isExcluded = false;
      if (zone.size() > 1) {
        ZoneRec zrec = zone.get(zone.size() - 2);
        if ((zrec.getGmtOffset() != rawOffset) && (zrec.getUntilTime(0) > Time.getCurrentTime())) {
          if (excludeList == null) {
            excludeList = new ArrayList<String>();
          }
          excludeList.add(zone.getName());
          isExcluded = true;
        }
      }

      if (!rawOffsetsIndex.contains(new Integer(rawOffset))) {
        // Find the index to insert this raw offset zones
        int n = rawOffsetsIndex.size();
        int i;
        for (i = 0; i < n; i++) {
          if (rawOffsetsIndex.get(i) > rawOffset) {
            break;
          }
        }
        rawOffsetsIndex.add(i, rawOffset);

        Set<String> perRawOffset = new TreeSet<String>();
        if (!isExcluded) {
          perRawOffset.add(zonename);
        }
        rawOffsetsIndexTable.add(i, perRawOffset);
      } else if (!isExcluded) {
        int i = rawOffsetsIndex.indexOf(new Integer(rawOffset));
        Set<String> perRawOffset = rawOffsetsIndexTable.get(i);
        perRawOffset.add(zonename);
      }
    }

    Map<String, String> a = zi.getAliases();
    // If there are time zone names which refer to any of the
    // excluded zones, add those names to the excluded list.
    if (excludeList != null) {
      for (String zoneName : a.keySet()) {
        String realname = a.get(zoneName);
        if (excludeList.contains(realname)) {
          excludeList.add(zoneName);
        }
      }
    }
    aliases.putAll(a);
  }
예제 #24
0
 @Test
 public void mergeZones() {
   Item item = new Item();
   item.setName("Battery");
   List<Item> items = new ArrayList<Item>();
   items.add(item);
   Zone genericZone =
       createZone(
           0,
           0,
           ZoneDanger.ONE_TO_THREE,
           -1,
           -1,
           false,
           false,
           false,
           false,
           null,
           null,
           null,
           null,
           0);
   Zone specificZone =
       createZone(
           0,
           0,
           ZoneDanger.NONE,
           2,
           5,
           true,
           true,
           true,
           true,
           items,
           "Huge Well",
           "2011-08-04 12:30:15",
           "Fred",
           8);
   genericZone.mergeZone(specificZone, 8);
   assertEquals(true, genericZone.isVisited());
   assertEquals(2, genericZone.getZombies());
   assertEquals(5, genericZone.getScoutSense());
   assertEquals(true, genericZone.isBluePrintRetrieved());
   assertEquals(true, genericZone.isBuildingDepleted());
   assertEquals(true, genericZone.isZoneDepleted());
   assertEquals(1, genericZone.getItems().size());
   assertEquals("Huge Well", genericZone.getScoutPeek());
 }
예제 #25
0
 public static PrimarySpiderDiagram getVennABCDiagramWithPartlyShadedBAndSpiderInZoneBC_A() {
   PrimarySpiderDiagram modelDiagram = getVennABCDiagramWithPartlyShadedB();
   HashMap<String, Region> habitats = new HashMap<>();
   habitats.put("s", new Region(Zone.fromInContours("B", "C").withOutContours("A")));
   return SpiderDiagrams.createPrimarySD(
       asList("s"), habitats, modelDiagram.getShadedZones(), modelDiagram.getPresentZones());
 }
    public String toString() {
      String str =
          "[Zone]\n"
              + "Name: "
              + iName
              + "\n"
              + "OffsetMillis: "
              + iOffsetMillis
              + "\n"
              + "Rules: "
              + iRules
              + "\n"
              + "Format: "
              + iFormat
              + "\n"
              + "UntilYear: "
              + iUntilYear
              + "\n"
              + iUntilDateTimeOfYear;

      if (iNext == null) {
        return str;
      }

      return str + "...\n" + iNext.toString();
    }
 void chain(StringTokenizer st) {
   if (iNext != null) {
     iNext.chain(st);
   } else {
     iNext = new Zone(iName, st);
   }
 }
예제 #28
0
  /**
   * Adds valid aliases to one of per-RawOffset table and removes invalid aliases from aliases List.
   * Aliases referring to excluded zones are not added to a per-RawOffset table.
   */
  void resolve() {
    int index = rawOffsetsIndexTable.size();
    List<String> toBeRemoved = new ArrayList<String>();
    for (String key : aliases.keySet()) {
      boolean validname = false;
      for (int j = 0; j < index; j++) {
        Set<String> perRO = rawOffsetsIndexTable.get(j);
        boolean isExcluded = (excludeList == null) ? false : excludeList.contains(key);

        if ((perRO.contains(aliases.get(key)) || isExcluded) && Zone.isTargetZone(key)) {
          validname = true;
          if (!isExcluded) {
            perRO.add(key);
            Main.info("Alias <" + key + "> added to the list.");
          }
          break;
        }
      }

      if (!validname) {
        Main.info("Alias <" + key + "> removed from the list.");
        toBeRemoved.add(key);
      }
    }

    // Remove zones, if any, from the list.
    for (String key : toBeRemoved) {
      aliases.remove(key);
    }
  }
예제 #29
0
  @Override
  public RRset next() {
    if (!this.hasNext()) {
      throw new NoSuchElementException();
    }
    if (current == null) {
      wantLastSoa = false;
      return originNode.getRRset(Type.SOA);
    }
    RRset set = current[count++];
    if (count == current.length) {
      current = null;
      while (domainIter.hasNext()) {

        String domainString = domainIter.next();
        if (domainString.equalsIgnoreCase(zone.getRootDomain())) {
          continue;
        }

        DomainResource dr = getDomainResource(domainString);
        if (dr == null) {
          continue;
        }
        List<RRset> sets = dr.getAllRRsets();
        if (sets == null || sets.size() == 0) {
          continue;
        }
        current = sets.toArray(new RRset[0]);
        count = 0;
        break;
      }
    }
    return set;
  }
예제 #30
0
 @Test
 public void
     areContoursDisjoint_should_return_true_when_the_spiders_are_not_in_the_shared_shaded_zones() {
   TreeMap<String, Region> habitats = new TreeMap<>();
   String spider = "s";
   habitats.put(spider, new Region(Zone.fromInContours("A", "C").withOutContours("B", "D")));
   Set<Zone> present = new HashSet<>();
   present.add(Zone.fromOutContours("A", "B", "C", "D"));
   PrimarySpiderDiagram diagramWithASpiderInTheIntersection =
       SpiderDiagrams.createPrimarySD(
           asList(spider),
           habitats,
           getZonesInsideAllContours(POWER_REGION_ABCD, "A", "D"),
           present);
   ContourRelations contourRelations = new ContourRelations(diagramWithASpiderInTheIntersection);
   assertTrue(contourRelations.areContoursDisjoint("A", "D"));
 }