@Override protected void buildGraphics() { GRect leftLeg = new GRect(35, 200, 35, 150); leftLeg.setColor(strokeColor); leftLeg.setFilled(true); leftLeg.setFillColor(strokeColor); addLeg(new Leg(leftLeg, 2)); GRect rightLeg = new GRect(75, 200, 35, 150); rightLeg.setColor(strokeColor); rightLeg.setFilled(true); rightLeg.setFillColor(strokeColor); addLeg(new Leg(rightLeg, 2)); GImage LlcoolJ = null; try { LlcoolJ = new GImage(ImageIO.read(getClass().getResource("/LLCOOLJ.png"))); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } getGraphics().add(LlcoolJ); addEye(Eye.createStandardEye(95, 20, 10, 0.26, 0.18, Color.RED)); addEye(Eye.createStandardEye(110, 30, 10, 0.26, 0.18, Color.RED)); }
@Override public View getPrototypeView(Context context) { prototypeView = View.inflate(context, R.layout.brick_phiro_rgb_light, null); TextView textValueRed = (TextView) prototypeView.findViewById(R.id.brick_phiro_rgb_led_red_prototype_text_view); textValueRed.setText(String.valueOf(BrickValues.PHIRO_VALUE_RED)); TextView textValueGreen = (TextView) prototypeView.findViewById(R.id.brick_phiro_rgb_led_green_prototype_text_view); textValueGreen.setText(String.valueOf(BrickValues.PHIRO_VALUE_GREEN)); TextView textValueBlue = (TextView) prototypeView.findViewById(R.id.brick_phiro_rgb_led_blue_prototype_text_view); textValueBlue.setText(String.valueOf(BrickValues.PHIRO_VALUE_BLUE)); Spinner eyeSpinner = (Spinner) prototypeView.findViewById(R.id.brick_phiro_rgb_light_spinner); eyeSpinner.setFocusableInTouchMode(false); eyeSpinner.setFocusable(false); eyeSpinner.setEnabled(false); ArrayAdapter<CharSequence> eyeAdapter = ArrayAdapter.createFromResource( context, R.array.brick_phiro_select_light_spinner, android.R.layout.simple_spinner_item); eyeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); eyeSpinner.setAdapter(eyeAdapter); eyeSpinner.setSelection(eyeEnum.ordinal()); return prototypeView; }
public PhiroRGBLightBrick(Eye eye, Formula red, Formula green, Formula blue) { this.eyeEnum = eye; this.eye = eyeEnum.name(); initializeBrickFields(red, green, blue); }
public PhiroRGBLightBrick(Eye eye, int red, int green, int blue) { this.eyeEnum = eye; this.eye = eyeEnum.name(); initializeBrickFields(new Formula(red), new Formula(green), new Formula(blue)); }
protected Object readResolve() { if (eye != null) { eyeEnum = Eye.valueOf(eye); } return this; }
@Override public View getView(Context context, int brickId, BaseAdapter baseAdapter) { if (animationState) { return view; } if (view == null) { alphaValue = 255; } view = View.inflate(context, R.layout.brick_phiro_rgb_light, null); setCheckboxView(R.id.brick_phiro_rgb_led_action_checkbox); final Brick brickInstance = this; checkbox.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { checked = isChecked; adapter.handleCheck(brickInstance, isChecked); } }); TextView textRed = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_red_prototype_text_view); editRedValue = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_action_red_edit_text); getFormulaWithBrickField(BrickField.PHIRO_LIGHT_RED) .setTextFieldId(R.id.brick_phiro_rgb_led_action_red_edit_text); getFormulaWithBrickField(BrickField.PHIRO_LIGHT_RED).refreshTextField(view); textRed.setVisibility(View.GONE); editRedValue.setVisibility(View.VISIBLE); editRedValue.setOnClickListener(this); TextView textGreen = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_green_prototype_text_view); editGreenValue = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_action_green_edit_text); getFormulaWithBrickField(BrickField.PHIRO_LIGHT_GREEN) .setTextFieldId(R.id.brick_phiro_rgb_led_action_green_edit_text); getFormulaWithBrickField(BrickField.PHIRO_LIGHT_GREEN).refreshTextField(view); textGreen.setVisibility(View.GONE); editGreenValue.setVisibility(View.VISIBLE); editGreenValue.setOnClickListener(this); TextView textBlue = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_blue_prototype_text_view); editBlueValue = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_action_blue_edit_text); getFormulaWithBrickField(BrickField.PHIRO_LIGHT_BLUE) .setTextFieldId(R.id.brick_phiro_rgb_led_action_blue_edit_text); getFormulaWithBrickField(BrickField.PHIRO_LIGHT_BLUE).refreshTextField(view); textBlue.setVisibility(View.GONE); editBlueValue.setVisibility(View.VISIBLE); editBlueValue.setOnClickListener(this); ArrayAdapter<CharSequence> eyeAdapter = ArrayAdapter.createFromResource( context, R.array.brick_phiro_select_light_spinner, android.R.layout.simple_spinner_item); eyeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); Spinner eyeSpinner = (Spinner) view.findViewById(R.id.brick_phiro_rgb_light_spinner); if (!(checkbox.getVisibility() == View.VISIBLE)) { eyeSpinner.setClickable(true); eyeSpinner.setEnabled(true); } else { eyeSpinner.setClickable(false); eyeSpinner.setEnabled(false); } eyeSpinner.setAdapter(eyeAdapter); eyeSpinner.setOnItemSelectedListener( new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) { eyeEnum = Eye.values()[position]; eye = eyeEnum.name(); adapterView = arg0; } @Override public void onNothingSelected(AdapterView<?> arg0) {} }); eyeSpinner.setSelection(eyeEnum.ordinal()); return view; }