Exemplo n.º 1
0
static elemstyle_icon_t *parse_icon(xmlNode *a_node) {
  elemstyle_icon_t *icon = g_new0(elemstyle_icon_t, 1);

  icon->annotate = xml_get_prop_is(a_node, "annotate", "true");

  icon->filename = (char*)xmlGetProp(a_node, BAD_CAST "src");
  g_assert(icon->filename);

  icon->filename = josm_icon_name_adjust(icon->filename);

  icon->zoom_max = 0;

  return icon;
}
Exemplo n.º 2
0
static void parse_style_node(xmlNode *a_node, xmlChar **fname, style_t *style) {
  xmlNode *cur_node = NULL, *sub_node = NULL;

  /* -------------- setup defaults -------------------- */
  /* (the defaults are pretty much the potlatch style) */
  style->background.color       = 0xffffffff; // white

  style->area.border_width      = 2.0;
  style->area.color             = 0x00000060; // 37.5%
  style->area.zoom_max          = 0.1111;     // zoom factor above which an area is visible & selectable

  style->node.radius            = 4.0;
  style->node.border_radius     = 2.0;
  style->node.color             = 0x000000ff; // black with filling ...
  style->node.fill_color        = 0x008800ff; // ... in dark green
  style->node.show_untagged     = FALSE;
  style->node.zoom_max          = 0.4444;     // zoom factor above which a node is visible & selectable

  style->track.width            = 6.0;
  style->track.color            = 0x0000ff40; // blue
  style->track.gps_color        = 0x000080ff;

  style->way.width              = 3.0;
  style->way.color              = 0x606060ff; // grey
  style->way.zoom_max           = 0.2222;     // zoom above which it's visible & selectable

  style->highlight.width        = 3.0;
  style->highlight.color        = 0xffff0080;  // normal highlights are yellow
  style->highlight.node_color   = 0xff000080;  // node highlights are red
  style->highlight.touch_color  = 0x0000ff80;  // touchnode and
  style->highlight.arrow_color  = 0x0000ff80;  // arrows are blue
  style->highlight.arrow_limit  = 4.0;

  style->frisket.mult           = 3.0;
  style->frisket.color          = 0xffffffff;
  style->frisket.border.present = TRUE;
  style->frisket.border.width   = 6.0;
  style->frisket.border.color   = 0x00000099;

  style->icon.enable            = FALSE;
  style->icon.scale             = 1.0;    // icon size (multiplier)

  for (cur_node = a_node->children; cur_node; cur_node = cur_node->next) {
    if (cur_node->type == XML_ELEMENT_NODE) {
      if(fname != NULL && strcasecmp((char*)cur_node->name, "elemstyles") == 0) {
	*fname = xmlGetProp(cur_node, BAD_CAST "filename");

	/* ---------- node ------------------------------------- */
      } else if(strcasecmp((char*)cur_node->name, "node") == 0) {
	parse_color(cur_node, "color", &style->node.color);
	parse_color(cur_node, "fill-color", &style->node.fill_color);
        style->node.radius = xml_get_prop_float(cur_node, "radius");
        style->node.border_radius = xml_get_prop_float(cur_node, "border-radius");
        style->node.zoom_max = parse_scale_max(cur_node);

	style->node.show_untagged =
	  xml_get_prop_is(cur_node, "show-untagged", "true");

	/* ---------- icon ------------------------------------- */
      } else if(strcasecmp((char*)cur_node->name, "icon") == 0) {
        style->icon.scale = xml_get_prop_float(cur_node, "scale");
	char *prefix = (char*)xmlGetProp(cur_node, BAD_CAST "path-prefix");
	if(prefix) {
	  g_free(style->icon.path_prefix);
	  style->icon.path_prefix = prefix;
	}
	style->icon.enable = xml_get_prop_is(cur_node, "enable", "true");

	/* ---------- way ------------------------------------- */
      } else if(strcasecmp((char*)cur_node->name, "way") == 0) {
	parse_color(cur_node, "color", &style->way.color);
        style->way.width = xml_get_prop_float(cur_node, "width");
        style->way.zoom_max = parse_scale_max(cur_node);

	/* ---------- frisket --------------------------------- */
      } else if(strcasecmp((char*)cur_node->name, "frisket") == 0) {
        style->frisket.mult = xml_get_prop_float(cur_node, "mult");
	parse_color(cur_node, "color", &style->frisket.color);
	style->frisket.border.present = FALSE;

	for(sub_node = cur_node->children; sub_node; sub_node=sub_node->next) {
	  if(sub_node->type == XML_ELEMENT_NODE) {
	    if(strcasecmp((char*)sub_node->name, "border") == 0) {
	      style->frisket.border.present = TRUE;
              style->frisket.border.width = xml_get_prop_float(sub_node, "width");

	      parse_color(sub_node, "color", &style->frisket.border.color);
	    }
	  }
	}

	/* ---------- highlight ------------------------------- */
      } else if(strcasecmp((char*)cur_node->name, "highlight") == 0) {
	parse_color(cur_node, "color", &style->highlight.color);
	parse_color(cur_node, "node-color", &style->highlight.node_color);
	parse_color(cur_node, "touch-color", &style->highlight.touch_color);
	parse_color(cur_node, "arrow-color", &style->highlight.arrow_color);
        style->highlight.width = xml_get_prop_float(cur_node, "width");
        style->highlight.arrow_limit = xml_get_prop_float(cur_node, "arrow-limit");

	/* ---------- track ------------------------------------ */
      } else if(strcasecmp((char*)cur_node->name, "track") == 0) {
	parse_color(cur_node, "color", &style->track.color);
	parse_color(cur_node, "gps-color", &style->track.gps_color);
        style->track.width = xml_get_prop_float(cur_node, "width");

	/* ---------- area ------------------------------------- */
      } else if(strcasecmp((char*)cur_node->name, "area") == 0) {
	style->area.has_border_color =
	  parse_color(cur_node, "border-color", &style->area.border_color);
        style->area.border_width = xml_get_prop_float(cur_node,"border-width");
        style->area.zoom_max = parse_scale_max(cur_node);

	parse_color(cur_node, "color", &style->area.color);

	/* ---------- background ------------------------------- */
      } else if(strcasecmp((char*)cur_node->name, "background") == 0) {
	parse_color(cur_node, "color", &style->background.color);

      } else
	printf("  found unhandled style/%s\n", cur_node->name);
    }
  }

  if(!style->icon.path_prefix)
    style->icon.path_prefix = g_strdup("standard");
}