public void specialShoot(Coordinate explodeCoordinate) { if (alive && hasItem()) // no time limit { if (item.getType().equals("nuke")) { world.addProjectile(new Nuke(this, explodeCoordinate)); item = null; } else if (item.getType().equals("starburst")) { world.addProjectile(new Starburst(this, explodeCoordinate, 2)); item = null; } else if (item.getType().equals("laser")) { world.addProjectile(new Laser(this, explodeCoordinate)); item = null; } /*else if(item.getType().equals("mine")) { world.addProjectile(new StarburstProjectile(this,explodeCoordinate,2)); item=null; }*/ else { System.out.println("unrecognised item shot: deleting..."); item = null; } } // ,color)); // System.out.println("tank shot"); }
private void manageDayView(TextView dayTV, ImageView dayIV, Item item) { dayTV.setText(item.getDay()); switch (item.getType()) { // apply styles case DEFAULT: { dayTV.setTextColor(getResources().getColor(R.color.black)); dayIV.setImageResource(R.drawable.calendarcell); dayIV.setTag(item); dayIV.setOnClickListener(this); } break; case LEAVEDAY: { ItemLeaveDay itemLeaveDay = (ItemLeaveDay) item; dayTV.setTextColor(getResources().getColor(R.color.black)); if (itemLeaveDay.getDuration() == Leave.Duration.AM) dayIV.setImageResource(R.drawable.calendarcell_sel_pm); else if (itemLeaveDay.getDuration() == Leave.Duration.PM) dayIV.setImageResource(R.drawable.calendarcell_sel_am); else dayIV.setImageResource(R.drawable.calendarcell_sel); dayIV.setTag(itemLeaveDay); dayIV.setOnClickListener( (itemLeaveDay.getDuration() == Leave.Duration.ONEDAY) ? null : this); } break; case NONWORKINGDAY: { dayTV.setTextColor(getResources().getColor(android.R.color.tertiary_text_light)); dayIV.setImageResource(R.drawable.calendarcell_na); dayIV.setOnClickListener(null); } break; } // let the selected items be colored blue on reuse if (leaveEndCalendar != null && tempEndLeaveEndCalendar != null) { if (item.getType() == ITEMTYPE.DEFAULT && item.getDate().compareTo(leaveEndCalendar.getTime()) >= 0 && item.getDate().compareTo(tempEndLeaveEndCalendar.getTime()) <= 0) { dayIV.setImageResource(R.drawable.calendarcell_leave); } else if (item.getType() == ITEMTYPE.LEAVEDAY && item.getDate().compareTo(tempEndLeaveEndCalendar.getTime()) == 0) { if (Math.abs(leaveDays.get(item.getStringedDate()) - 0.1) < 0.00001) dayIV.setImageResource(R.drawable.calendarcell_leave_am_whole); else dayIV.setImageResource(R.drawable.calendarcell_leave_pm_whole); } } }
public Item itemOfType(String type) { for (Item it : itemList) { if (it.getType().equals(type)) { return it; } } return null; }
private void addToChildrenResourceGrid(ExplorerGrid grid, Item item) { Object[] cols = new Object[2]; cols[0] = item.getName(); cols[1] = item.getType(); grid.addRow(grid.getRowCount(), cols); }
private void addToPropertyGrid(ExplorerGrid grid, Item item) { Object[] cols = new Object[4]; cols[0] = item.getName(); cols[1] = item.getType(); cols[2] = item.getValue(); cols[3] = item.isMutli().toString(); grid.addRow(grid.getRowCount(), cols); }
/** * Checks to see if this getArray() has one slot that has the item id and equal or more to the * amount. * * @param type item to look for * @param minimum amount of items that must be in the stack * @return */ public boolean hasItem(Item.Type type, int minimum) { Item[] items = getContents(); for (Item item : items) { if ((item != null) && (item.getType() == type) && (item.getAmount() >= minimum)) { return true; } } return false; }
public View getView(int paramInt, View paramView, ViewGroup paramViewGroup) { Item item = items.get(paramInt); final ViewHolder localViewHolder; if (paramView == null) { paramView = this.inflater.inflate(R.layout.flip_item, paramViewGroup, false); localViewHolder = new ViewHolder(); localViewHolder.celebrityIdentity = (TextView) paramView.findViewById(R.id.celeb_identity); localViewHolder.celebrityDetails = (TextView) paramView.findViewById(R.id.celeb_details); localViewHolder.readMore = (TextView) paramView.findViewById(R.id.more_read); localViewHolder.celebrityType = (TextView) paramView.findViewById(R.id.celeb_type); localViewHolder.celebrityImg = (ImageView) paramView.findViewById(R.id.celeb_img); localViewHolder.celebrityIdentity.setTypeface(futuraTypeface); localViewHolder.celebrityDetails.setTypeface(futuraTypeface); localViewHolder.readMore.setTypeface(muktiTypeface); localViewHolder.celebrityType.setTypeface(muktiTypeface); paramView.setTag(localViewHolder); } else { localViewHolder = (ViewHolder) paramView.getTag(); } localViewHolder.celebrityIdentity.setText(item.getIdentity()); localViewHolder.celebrityType.setText(item.getType()); localViewHolder.celebrityDetails.setText(item.getDetails()); localViewHolder.celebrityImg.setImageResource(item.getImage()); localViewHolder.readMore.setText("আরো পড়ুন"); ViewTreeObserver vto = localViewHolder.celebrityDetails.getViewTreeObserver(); vto.addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { localViewHolder .celebrityDetails .getViewTreeObserver() .removeGlobalOnLayoutListener(this); int height = localViewHolder.celebrityDetails.getMeasuredHeight(); int numLineHight = localViewHolder.celebrityDetails.getLineHeight(); int txtHeight = (int) (height / numLineHight); localViewHolder.celebrityDetails.setMaxLines(txtHeight); } }); return paramView; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(item.getType().getLongId()); sb.append(','); sb.append(item.getIdentifier()); sb.append(','); sb.append(color.toString()); sb.append("->"); sb.append(elementId); return sb.toString(); }
/* (non-Javadoc) * @see org.exist.xquery.value.Sequence#add(org.exist.xquery.value.Item) */ public void add(Item item) throws XPathException { if (hasOne) { hasOne = false; } if (isEmpty) { hasOne = true; } isEmpty = false; if (count == items.length) { Entry newItems[] = new Entry[count * 2]; System.arraycopy(items, 0, newItems, 0, count); items = newItems; } items[count++] = new Entry(item); checkItemType(item.getType()); }
/** * Month conversion from entity object to jaxb model. * * @param data month entity object * @return jaxb model of month */ public static Month transformMonthToModel(org.kaleta.scheduler.backend.entity.Month data) { Month model = new Month(); model.setId(String.valueOf(data.getId())); Month.Specification specification = new Month.Specification(); specification.setName(data.getName()); specification.setDays(String.valueOf(data.getDaysNumber())); specification.setFirstDay(String.valueOf(data.getDayStartsWith())); for (Integer day : data.getPublicFreeDays()) { Month.Specification.FreeDay freeDay = new Month.Specification.FreeDay(); freeDay.setDay(String.valueOf(day)); specification.getFreeDayList().add(freeDay); } model.setSpecification(specification); Month.Schedule schedule = new Month.Schedule(); for (Task task : data.getTasks()) { Month.Schedule.Task taskModel = new Month.Schedule.Task(); taskModel.setId(String.valueOf(task.getId())); taskModel.setType(task.getType()); taskModel.setDescription(task.getDescription()); taskModel.setDay(String.valueOf(task.getDay())); taskModel.setStarts(task.getStarts().toString()); taskModel.setDuration(task.getDuration().toString()); taskModel.setPriority(String.valueOf(task.getPriority())); taskModel.setSuccessful(String.valueOf(task.getSuccessful())); schedule.getTaskList().add(taskModel); } model.setSchedule(schedule); Month.Accounting accounting = new Month.Accounting(); for (Item item : data.getItems()) { Month.Accounting.Item itemModel = new Month.Accounting.Item(); itemModel.setId(String.valueOf(item.getId())); itemModel.setType(item.getType()); itemModel.setDescription(item.getDescription()); itemModel.setDay(String.valueOf(item.getDay())); itemModel.setIncome(String.valueOf(item.getIncome())); itemModel.setAmount(String.valueOf(item.getAmount())); accounting.getItemList().add(itemModel); } model.setAccounting(accounting); return model; }
public int compareTo(Item item) { if (item == null) { return BigInteger_ZERO.equals(value) ? 0 : 1; // 1.0 == 1, 1.1 > 1 } switch (item.getType()) { case INTEGER_ITEM: return value.compareTo(((IntegerItem) item).value); case STRING_ITEM: return 1; // 1.1 > 1-sp case LIST_ITEM: return 1; // 1.1 > 1-1 default: throw new RuntimeException("invalid item: " + item.getClass()); } }
public int compareTo(Item item) { if (item == null) { // 1-rc < 1, 1-ga > 1 return comparableQualifier(value).compareTo(RELEASE_VERSION_INDEX); } switch (item.getType()) { case INTEGER_ITEM: return -1; // 1.any < 1.1 ? case STRING_ITEM: return comparableQualifier(value) .compareTo(comparableQualifier(((StringItem) item).value)); case LIST_ITEM: return -1; // 1.any < 1-1 default: throw new RuntimeException("invalid item: " + item.getClass()); } }
private PreviewProperty[] createLegendProperties(Item item) { if (setDefaultValues()) { updateDefaultValues(); } int[] properties = LegendProperty.LIST_OF_PROPERTIES; PreviewProperty[] previewProperties = new PreviewProperty[defaultValuesArrayList.size()]; // creating label Integer itemIndex = item.getData(LegendItem.ITEM_INDEX); previewProperties[0] = createLegendProperty( item, LegendProperty.LABEL, defaultLabel + itemIndex + " [" + item.getType() + "]"); for (int i = 1; i < previewProperties.length; i++) { previewProperties[i] = createLegendProperty(item, properties[i], defaultValuesArrayList.get(i)); } return previewProperties; }
/** * Function that takes an item and saves its data, legend properties, specific item properties, * dynamic properties and data using the specified writer. * * @param writer the XMLStreamWriter to write to * @param item the item to be saved * @param previewProperties Current workspace PreviewProperties * @throws XMLStreamException */ public void writeXMLFromItem( XMLStreamWriter writer, Item item, PreviewProperties previewProperties) throws XMLStreamException { // legend type writer.writeStartElement(XML_LEGEND_TYPE); writer.writeCharacters(item.getType()); writer.writeEndElement(); // renderer writer.writeStartElement(XML_RENDERER); System.out.println("" + item.getData(LegendItem.RENDERER).getClass().getName()); writer.writeCharacters(item.getData(LegendItem.RENDERER).getClass().getName()); writer.writeEndElement(); // legend properties writer.writeStartElement(XML_LEGEND_PROPERTY); PreviewProperty[] legendProperties = item.getData(LegendItem.PROPERTIES); for (PreviewProperty property : legendProperties) { writeXMLFromSingleProperty(writer, property, previewProperties); } writer.writeEndElement(); // own properties writer.writeStartElement(XML_OWN_PROPERTY); writeXMLFromItemOwnProperties(writer, item, previewProperties); writer.writeEndElement(); // dynamic properties writer.writeStartElement(XML_DYNAMIC_PROPERTY); writeXMLFromDynamicProperties(writer, item, previewProperties); writer.writeEndElement(); // data writer.writeStartElement(XML_DATA); writeXMLFromData(writer, item, previewProperties); writer.writeEndElement(); }
public int compareTo(Item item) { if (item == null) { if (size() == 0) { return 0; // 1-0 = 1- (normalize) = 1 } Item first = get(0); return first.compareTo(null); } switch (item.getType()) { case INTEGER_ITEM: return -1; // 1-1 < 1.0.x case STRING_ITEM: return 1; // 1-1 > 1-sp case LIST_ITEM: Iterator<Item> left = iterator(); Iterator<Item> right = ((ListItem) item).iterator(); while (left.hasNext() || right.hasNext()) { Item l = left.hasNext() ? left.next() : null; Item r = right.hasNext() ? right.next() : null; // if this is shorter, then invert the compare and mul with -1 int result = l == null ? -1 * r.compareTo(l) : l.compareTo(r); if (result != 0) { return result; } } return 0; default: throw new RuntimeException("invalid item: " + item.getClass()); } }
/** * 获取物品的类型 * * @param item * @return */ public static int getType(Item item) { return Integer.valueOf(item.getType(), 16); }
public int getMaxDurability(Slot slot) { Item<?> item = getItem(slot); return item == null ? 0 : item.getType().getMaxDurability(); }
public int getTypeId(Slot slot) { Item<?> item = getItem(slot); return item == null ? -1 : item.getType().getTypeId(); }